Repository navigation
Conversation
CORS refusals, unknown routes, and /refresh with no token or one that matches no session each wrote an audit event and took the chain head lock. They are now counted in process with a per-minute log summary. Stored user agents and refused bearer routes are capped. Refs #596
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #596.
Problem
Several refusals that any caller can produce for free wrote a hash-chained
AuthEvent:POST /refreshwith no token, or with a token that matches no sessionEach write took the chain head row lock and stored the raw user agent and, for 404s,
originalUrl. A scanner at the general rate limit could grow the trail and queue real sign-ins behind its writes.Changes
Counted, not recorded. These refusals are counted in process in the new
src/services/unauthenticatedRefusals.ts. Each instance logs one summary line at most once a minute, when it sees one:Unauthenticated refusals in the last 60s: unknown_route=... cors_origin_refused=.... The line carries no paths, origins or token material.Issued tokens are still recorded. A refresh token that matches a session is still a
refresh_token_failedrow. A revoked session is now recorded against its session and user. It used to be lumped in with unknown tokens and had neither.Caps where rows are still written.
user_agentis capped at 512 characters, the same limit the trusted client user agent header already had.bearer_token_failed) is capped at 256 characters, because it falls back to the request path when no route pattern matched.Docs.
docs/security-posture.md, "Refusals at the auth gate", gains "Other free refusals", which lists what is counted and why, and the caps. The CORS section no longer says the refusal writes arequest_suspiciousrow.Contract impact
No route, schema, token or status code changes.
There is a behavioural change for readers of the trail.
request_suspiciousrows for unknown routes and refused origins, andrefresh_token_failedrows for unknown tokens, stop appearing. The admin dashboard andGET /internal/security/anomalieswill show far fewer suspicious events. Their response shapes are unchanged.Verification
npm run typecheck,npm run lintandnpm run format:checkpass.npm run coveragepasses: 196 files, 3447 tests, 99.08% lines, 95.83% branches.npm run generate:apiproduced no diff.TEST_DB=postgressuite passes against a scratch Postgres (19 files, 283 tests).