Skip to content

Document actual debug routes and fix rate limiter IP resolution#60

Open
GsCommand wants to merge 1 commit into
mainfrom
claude/audit-commandlayer-protocol-7kpEB
Open

Document actual debug routes and fix rate limiter IP resolution#60
GsCommand wants to merge 1 commit into
mainfrom
claude/audit-commandlayer-protocol-7kpEB

Conversation

@GsCommand
Copy link
Copy Markdown
Contributor

Summary

This PR corrects documentation to match the actual implemented debug API surface and fixes a security issue in the rate limiter's IP resolution logic.

Key Changes

Documentation updates (README.md):

  • Added /execute endpoint to the documented API surface
  • Replaced outdated debug route documentation (/debug/env, /debug/enskey, /debug/validators, /debug/prewarm) with the actually implemented routes:
    • GET /debug/signer — active signer state, kid, fingerprint, and boot errors
    • GET /debug/ens — ENS resolution result with optional query parameters
    • GET /debug/schema/:verb — schema compilation status for a given verb
  • Updated references to schema validation behavior to point to /debug/schema/:verb instead of the non-existent /debug/prewarm and /debug/validators
  • Removed note about missing /debug/schemafetch route (no longer relevant)

Rate limiter security fix (src/middleware/rateLimit.mjs):

  • Changed IP resolution from reading the raw X-Forwarded-For header directly to using Express's req.ip (which respects the trust proxy setting)
  • This prevents callers from injecting arbitrary IP strings to bypass per-IP rate limiting
  • Added explanatory comment documenting the security rationale

Test updates (tests/smoke.mjs):

  • Updated smoke test to call the actual /debug/signer endpoint instead of the non-existent /debug/env
  • Updated error messages and logging to reference the correct endpoint

Contract Impact

No hard contracts broken. Documentation now accurately reflects the implemented runtime API surface. Rate limiter behavior is more secure and aligns with Express best practices for proxy trust.

https://claude.ai/code/session_016igMwkFir2FkLQCHL6a34z

…smoke test dead endpoint

- src/middleware/rateLimit.mjs: use req.ip (Express trust-proxy-resolved) instead
  of reading X-Forwarded-For directly. The previous code allowed any caller to
  inject an arbitrary IP via the X-Forwarded-For header and bypass per-IP rate
  limiting entirely. With trust proxy: 1 set in server.mjs, req.ip is already
  correctly resolved by Express to the first untrusted hop.

- README.md: correct the debug routes section. The documented routes
  (/debug/env, /debug/enskey, /debug/validators, POST /debug/prewarm) do not
  exist in server.mjs. The actual implemented routes are /debug/signer,
  /debug/ens, and /debug/schema/:verb. Updated to match implementation.

- tests/smoke.mjs: remove reference to non-existent /debug/env endpoint in the
  error-branch debug path. Replace with /debug/signer which is the implemented
  equivalent. The dead reference would have produced a 404 JSON body in debug
  output, obscuring the actual signer error.

AUDIT: remaining CRITICAL issues (no auth on verb routes, no 422 responses)
require architectural decisions and are flagged for engineering review.
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