Skip to content

Security hardening from audit#1

Open
DROOdotFOO wants to merge 2 commits into
mainfrom
fix/security-hardening
Open

Security hardening from audit#1
DROOdotFOO wants to merge 2 commits into
mainfrom
fix/security-hardening

Conversation

@DROOdotFOO

Copy link
Copy Markdown
Contributor

Summary

Security hardening pass based on audit against 2026 threat landscape ($482M stolen YTD, 76% infrastructure attacks).

Critical/High fixes:

  • API key timing leak: pad buffers to equal length before timingSafeEqual
  • Circuit breaker auto-reset: resumes after 24h window elapses instead of requiring manual intervention
  • Rate limiter: exported class, 8 new tests (tests/rate-limiter.test.ts)
  • Health check /status now rate-limited
  • Type-safe receipt handling: replaced as unknown as Record casts with runtime guards
  • Reject zero-amount transfers (regex ^[1-9]\d*$)
  • Audit log file created with 0o600 permissions

Noir contract hardening:

  • initialize_public_state and apply_limits validate daily_limit >= max_per_tx and u64 range
  • New reset_daily_spent() admin function for epoch stall recovery
  • Artifact recompiled with nargo compile

Production readiness:

  • Docker HEALTHCHECK (30s interval, curl /status)
  • Non-localhost bind warning (recommends TLS reverse proxy)
  • TODO.md updated with security hardening section

Test plan

  • npm run typecheck -- clean
  • npm test -- 127/127 pass (8 files, including new rate-limiter tests)
  • nargo compile -- Noir artifact valid (1.65MB)
  • Bloo reviews Noir contract changes (limit validation, admin reset)
  • Verify Docker build with HEALTHCHECK

Fix API key timing leak (pad buffers to equal length),
circuit breaker auto-reset after window, reject zero
amounts, restrict audit log perms, rate limit /status,
type-safe receipt handling, non-localhost TLS warning,
Docker HEALTHCHECK. Noir contract: limit validation,
admin reset_daily_spent, recompiled artifact. Rate
limiter exported with 8 new tests.
@DROOdotFOO DROOdotFOO requested a review from bloo-berries April 20, 2026 21:15
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