Repository navigation
Conversation
- Server: double-submit CSRF tokens (csrf-csrf) bound to the session, required on all state-changing requests; new GET /api/csrf-token. - Server: express-rate-limit on /api/maintenance (30/min) with a tighter limit on writes (10/min). - Client: axios interceptor fetches and attaches x-csrf-token on mutating requests, refreshing on session change or a rejected token. - Tests: jest suites for server CSRF, server DoS, and client CSRF behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Fixes two vulnerabilities in the maintenance requests feature.
CSRF. Write routes previously trusted the auth cookie alone, so any site the user visited could forge requests in their name.
csrf-csrf) bound to the user's session. Every POST/PUT/PATCH/DELETE must send a valid token in thex-csrf-tokenheader, except login and register. Invalid or missing tokens get a 403.GET /api/csrf-tokenhands the client its token.DoS. There was no rate limiting, so the public list endpoint could be flooded.
express-rate-limitcaps/api/maintenanceat 30 requests per minute per client, and writes at 10 per minute. Excess requests get a 429 before any auth check or database query runs.Tests
npm test..github/workflows/test.yml) that runsnpm teston every push and pull request.All 6 tests pass locally and on GitHub Actions.
Configuration
Set
CSRF_SECRETinserver/.env. Without it, the server generates a random secret at startup, so tokens stop working after a restart.🤖 Generated with Claude Code