security(#147): Implement JWT token expiration to prevent perpetual sessions#273
Open
anshul23102 wants to merge 1 commit into
Open
security(#147): Implement JWT token expiration to prevent perpetual sessions#273anshul23102 wants to merge 1 commit into
anshul23102 wants to merge 1 commit into
Conversation
… vulnerability - Add 7-day expiration to JWT tokens on signin - Include expiresIn in API response for client awareness - Prevent indefinite token validity and session hijacking - Reduce impact of token compromise or leakage - Implement standard JWT security practice Security Impact: - Closes critical vulnerability allowing perpetual session tokens - Limits credential validity to 7 days - Requires users to re-authenticate after expiration - Reduces attack surface for token compromise Fixes chthonn#147
Contributor
|
@anshul23102 is attempting to deploy a commit to the Sunil Kumar's projects Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
Please add labels:
|
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.
Problem Statement
CRITICAL SECURITY VULNERABILITY: Perpetual JWT Session Tokens
JWT authentication tokens issued during signin have no expiration. Once issued, a token remains valid indefinitely, creating permanent session hijacking risk.
Vulnerability Details
Location: server/src/routes/auth.js (lines 288-291)
Issue: JWT tokens are created without expiration
Attack Scenario:
Impact:
Solution Implemented
1. JWT Expiration Configuration
Added
expiresIn: "7d"option to jwt.sign() for 7-day token expiration2. Client Response Update
Include expiration info in signin response so clients know token lifetime
3. Middleware Validation
Existing
jwt.verify()in auth middleware automatically rejects expired tokensSecurity Benefits
Configuration Details
Token Expiration: 7 Days
Rationale:
Testing
Deployment Notes
Fixes #147