Skip to content

Fix/issue 2088 jwt token replay - #2097

Merged
Dev1822 merged 3 commits into
Dev1822:mainfrom
Vachhani-Tapan:fix/issue-2088-jwt-token-replay
Aug 31, 2026
Merged

Fix/issue 2088 jwt token replay#2097
Dev1822 merged 3 commits into
Dev1822:mainfrom
Vachhani-Tapan:fix/issue-2088-jwt-token-replay

Conversation

@Vachhani-Tapan

Copy link
Copy Markdown

Fix: JWT Token Replay Vulnerability

Resolves#2088

Description

This PR addresses a high-risk security vulnerability where JWT tokens remained valid on the server even after explicit user logout, allowing potential session hijacking and token replay attacks.

Code Changes

  • backend/src/controllers/user.controller.js: During logout, the access token is now intercepted and explicitly written to a stateful Redis blacklist (setex blacklist:<token> <TTL> true). The TTL matches the token's remaining time to naturally expire, preventing unbounded memory growth in Redis.
  • backend/src/middlewares/auth.middleware.js: Added a verification step immediately following token signature validation. The middleware now queries Redis; if the JWT token is present in the blacklist, the request is immediately rejected with a 401 Unauthorized.

Verification

  • Verified token is actively pushed to Redis upon logout.
  • Confirmed subsequent requests with the blacklisted token are blocked with HTTP 401.

@vercel

vercelBot commented Aug 31, 2026

Copy link
Copy Markdown

@Vachhani-Tapan is attempting to deploy a commit to the Dev's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Dev1822Dev1822 added bug Something isn't working ECSoC26 good-pr labels Aug 31, 2026
@Dev1822
Dev1822 merged commit 3a15c07 into Dev1822:mainAug 31, 2026
5 of 20 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugSomething isn't workingECSoC26-L3ECSoC26good-pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] JWT Token Replay Vulnerability

2 participants

@Vachhani-Tapan@Dev1822