Skip to content

fix(core): revoke active JWT tokens after logout#2571

Open
Sourav-kashyap wants to merge 1 commit into
masterfrom
GH-2570
Open

fix(core): revoke active JWT tokens after logout#2571
Sourav-kashyap wants to merge 1 commit into
masterfrom
GH-2570

Conversation

@Sourav-kashyap

Copy link
Copy Markdown
Contributor

GH-2570

JWT Logout Security Fix

Problem Statement

Security Vulnerability: JWT Tokens Remain Valid After Logout

Issue: When a user logs out of the system, their JWT access token remains valid until its natural expiration time, allowing the token to be used for authenticated requests even after logout.

Impact: This creates a security vulnerability where:

  1. Logged-out users retain access to protected APIs until their JWT naturally expires
  2. Session invalidation through logout is ineffective
  3. In case of security incidents, compromised tokens cannot be immediately revoked
  4. Access token lifetime becomes the effective session lifetime, regardless of logout

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • Performed a self-review of my own code
  • npm test passes on your machine

Build:

Screenshot 2026-06-19 at 6 14 25 PM

Test:

Screenshot 2026-06-19 at 6 14 41 PM

revoke active JWT tokens after logout

GH-2570
@Sourav-kashyap Sourav-kashyap self-assigned this Jun 19, 2026
@Sourav-kashyap Sourav-kashyap requested a review from a team as a code owner June 19, 2026 12:50
@Sourav-kashyap Sourav-kashyap linked an issue Jun 19, 2026 that may be closed by this pull request
@sonarqubecloud

Copy link
Copy Markdown

SonarQube reviewer guide

Summary: Add token revocation checking to bearer token verification by introducing a utility function that validates tokens against a revoked token repository across both symmetric and asymmetric token verifiers.

Review Focus:

  • The new checkIfTokenRevoked utility's error handling strategy—it silently logs repository errors rather than failing verification. Verify this graceful degradation approach is intentional and acceptable for security.
  • Ensure the revocation check executes early enough in the verification flow to prevent unnecessary downstream processing.
  • Confirm the RevokedTokenRepository.get() method efficiently handles token lookups.

Start review at: packages/core/src/components/bearer-verifier/providers/utils/revoked-token-checker.util.ts. This is the core security logic; understanding its error handling and performance characteristics is essential before reviewing its integration points.

💬 Please send your feedback

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

value(): VerifyFunction.BearerFn {
return async (token: string) => {
// Check if token has been revoked
await checkIfTokenRevoked(token, this.revokedTokenRepo, this.logger);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are we revoking this token actually ?

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.

Security Vulnerability: JWT Tokens Remain Valid After Logout

2 participants