Skip to content

feat(security): harden refresh-token rotation with hashed storage, replay detection, and denylist revocation (Fixes #104) - #152

Open
Sanjai-Gopal wants to merge 18 commits into
sidd190:mainfrom
Sanjai-Gopal:feat/hardened-refresh-token-rotation
Open

Sanjai-Gopal wants to merge 18 commits into
sidd190:mainfrom
Sanjai-Gopal:feat/hardened-refresh-token-rotation

Conversation

@Sanjai-Gopal

@Sanjai-Gopal Sanjai-Gopal commented Nov 17, 2026 •

Copy link
Copy Markdown

Summary

Fixes #104. Hardens refresh token security in the authentication backend to mitigate token theft, credential stuffing, and session replay attacks.

Changes

  • Hashed Token Storage: Stored refresh tokens are hashed with SHA-256 before writing to MongoDB, preventing database dumps from exposing valid credentials.
  • Replay Detection & Family Invalidation: If an already-consumed refresh token is submitted, the authentication backend revokes all tokens for that user session family immediately.
  • Revocation Denylist: In-memory and database-backed denylist with unref'd TTL timer cleanup for rotated and invalidated tokens.
  • Distinct Secrets: Enforces separate signing keys (JWT_ACCESS_SECRET vs JWT_REFRESH_SECRET) so access tokens cannot be used to refresh sessions.

Verification

  • npm test: 82/82 automated tests passing across 11 test suites without open socket warnings.
  • npm run lint: 0 ESLint errors/warnings.
  • npm run build: Babel production compilation succeeds.

Sanjai Gopal added 17 commits November 16, 2026 20:55
…play detection, and denylist revocation (closes sidd190#104)
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c2cde326-7d98-45af-8097-b3567428b019
Commits

Reviewing files that changed from the base of the PR and between 805e9f4 and 298db2b.

Files ignored due to path filters: 1

  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing: 18

  • README.md
  • backend/__tests__/authMiddleware.test.js
  • backend/__tests__/passwordPolicy.test.js
  • backend/__tests__/secretEnforcement.test.js
  • backend/__tests__/sessionRevocation.test.js
  • backend/__tests__/tokenSecurity.test.js
  • backend/__tests__/userSchema.test.js
  • backend/index.js
  • backend/middleware/auth.js
  • backend/models/User.js
  • backend/routes/auth.js
  • backend/services/tokenDenylist.js
  • docs/API_REFERENCE.md
  • docs/THREAT_MODEL.md
  • frontend/src/components/SetPasswordButton.jsx
  • llms-full.txt
  • llms.txt
  • package.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Sanjai-Gopal Sanjai-Gopal changed the title Feat/hardened refresh token rotation feat(security): harden refresh-token rotation with hashed storage, replay detection, and denylist revocation (Fixes #104) Nov 18, 2026
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.

Harden refresh-token rotation (hashed storage, replay detection, revocation)

1 participant