Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Fix Incomplete Token Revocation Bypass - #33

Draft
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
sentinel/fix-token-revocation-13637368393360242523
Draft

πŸ›‘οΈ Sentinel: [HIGH] Fix Incomplete Token Revocation Bypass#33
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
sentinel/fix-token-revocation-13637368393360242523

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

πŸ›‘οΈ Sentinel: [CRITICAL/HIGH] Fix Incomplete Token Revocation Bypass

🚨 Severity: HIGH

πŸ’‘ Vulnerability: The application implemented a token blacklist mechanism in AuthService but failed to enforce it in the API routes. The inline preHandler hooks only called request.jwtVerify(), which validates the signature and expiration but ignores the blacklist. This meant that a "logged out" token (present in the blacklist) could still be used to access protected endpoints until it naturally expired.

🎯 Impact: User sessions persist after logout, allowing potential attackers to use stolen tokens even after the user has revoked them via logout.

πŸ”§ Fix:

  1. Created backend/src/shared/middleware/auth.middleware.ts which performs both jwtVerify() and AuthService.isTokenBlacklisted().
  2. Refactored all protected routes (auth, user, project, ama, analytics) to use this centralized middleware instead of ad-hoc checks.
  3. Added unit tests to verify the middleware correctly rejects blacklisted tokens.

βœ… Verification:

  1. Run cd backend && npm test to verify the new middleware tests pass.
  2. Manual verification (concept): Login -> Get Token -> Access Protected Route (Success) -> Logout -> Access Protected Route (Should Fail 401).

PR created automatically by Jules for task 13637368393360242523 started by @Magnopiro-oficial

- Created `backend/src/shared/middleware/auth.middleware.ts` to centralize JWT verification and blacklist checking.
- Refactored `auth`, `user`, `project`, `ama`, and `analytics` routes to use the new `authenticate` middleware.
- Removed insecure inline `preHandler` blocks that skipped revocation checks.
- Added `backend/jest.config.js` and `backend/jest.setup.js` to enable testing.
- Added unit tests for the authentication middleware.
- Documented vulnerability in `.jules/sentinel.md`.

This fixes a critical vulnerability where revoked tokens (e.g., after logout) could still be used to access protected endpoints.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

0 participants