Skip to content

Fix input validation DoS and in-flight timer recovery#11

Merged
nisfeb merged 1 commit into
masterfrom
fix/input-validation-dos
Mar 20, 2026
Merged

Fix input validation DoS and in-flight timer recovery#11
nisfeb merged 1 commit into
masterfrom
fix/input-validation-dos

Conversation

@nisfeb
Copy link
Copy Markdown
Contributor

@nisfeb nisfeb commented Mar 20, 2026

Summary

Three security/reliability fixes from final review:

  1. Empty body crash (DoS): all POST handlers called (need body.request.req) which crashes on missing body. Now uses require-body/require-json-body helpers that return error responses.
  2. Invalid hex crash (DoS): from-hex used !! on non-hex chars. Added from-hex-safe returning (unit @) for all user-facing endpoints (signature, ciphertext, ephemeral pubkey, MAC).
  3. In-flight timer recovery: ship restart lost Behn timers, stranding in-flight tokens forever. on-load now re-arms recovery timers for existing in-flight entries.

Test plan

  • POST /vitriol/verify-commit with empty body returns JSON error, not crash
  • POST /vitriol/verify-commit with "signature":"ZZZZ" returns error, not crash
  • POST /vitriol/admin/ban with empty body redirects, not crash
  • Agent restart preserves in-flight tokens and schedules recovery

Security fixes:
- All POST handlers: check for missing request body before parsing.
  Previously (need body.request.req) crashed the agent on empty POST.
  Now returns redirect (forms) or JSON error (API) gracefully.
- from-hex: no longer crashes on invalid hex chars (was !!). Added
  from-hex-safe that returns (unit @) for user-facing endpoints.
  Invalid hex in signature, ciphertext, ephemeral pubkey, or MAC
  fields now returns an error instead of crashing.
- require-body/require-json-body helpers for safe body extraction.

Bug fix:
- In-flight token timers re-armed on agent restart. Previously,
  ship restart lost all Behn timers, leaving in-flight tokens
  stranded forever. on-load now schedules recovery timers for
  any existing in-flight entries.
@nisfeb nisfeb force-pushed the fix/input-validation-dos branch from e3eeb1a to acb479f Compare March 20, 2026 18:43
@nisfeb nisfeb merged commit 5ea19d0 into master Mar 20, 2026
1 check passed
@nisfeb nisfeb deleted the fix/input-validation-dos branch March 20, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant