Iām looking for suggestions from developers, security engineers, and penetration testers who have handled similar issues in production applications.
I recently came across an interesting security scenario involving JWT token reuse, session termination, and Burp Suite response manipulation.
1ļøā£ The Scenario
My application has:
- āļø React frontend
- ā Spring Boot backend
- š JWT-based authentication
- š HTTPS
- š”ļø Role and permission-based authorization
During security testing, the tester captures a valid access token and attempts to reuse it after the token has expired or the session has been terminated.
Expected behavior
User Login
ā
Access Token Issued
ā
Token Expires / Session Terminates
ā
Old Token Becomes Invalid
ā
Attacker Replays Old Token
ā
Backend Rejects Request
The main requirement is:
An expired, revoked, or terminated token must never be accepted for a protected API operation.
2ļøā£ The Interesting Part ā Burp Suite
There is another aspect that makes this scenario interesting.
Suppose the backend correctly identifies the token as invalid and returns:
HTTP/1.1 401 Unauthorized
The tester can intercept the response using Burp Suite and change it to:
HTTP/1.1 200 OK
before the response reaches the React application.
Flow
Attacker
ā
Expired / Invalid Token
ā
Spring Boot
ā
401 Unauthorized
ā
Burp Suite
ā
401 ā 200
ā
React receives modified response
I understand that the browser is an untrusted environment and that an attacker controlling their browser can modify HTTP requests and responses.
However, my question is:
What is the industry-standard approach to ensure that this type of manipulation cannot result in an actual unauthorized server-side operation?
3ļøā£ What I Have Already Considered
š Authentication
- Short-lived access tokens
- JWT signature validation
- JWT expiration validation
- Refresh-token rotation
- HttpOnly + Secure cookies
š« Token / Session Management
- Server-side session invalidation
- Token/session versioning
- Token revocation
- Invalidating previously issued tokens after logout
š® Authorization
- Permission validation on every protected API
- Role-based authorization
- Server-side authorization
- Never trusting frontend role/permission information
4ļøā£ Token Replay Scenario
For example, suppose an attacker captures:
Token A
Later:
Token A
ā
Expires / Session Terminated
ā
Attacker Replays Token A
ā
Protected API
The backend should independently validate:
JWT Signature
ā
Expiration
ā
Session Validity
ā
Token Status
ā
User Status
ā
Permission
ā
Business Authorization
Only if all validations succeed should the operation be performed.
5ļøā£ Expected Security Model š”ļø
Attacker Captures Token A
ā
Token A Expires / Session Terminates
ā
Attacker Replays Token A
ā
Backend Independently Validates
ā
āāā š JWT Signature
āāā ā³ Expiration
āāā š Session Validity
āāā š« Token Status
āāā š¤ User Status
āāā š® Authorization
ā
REJECT
ā
Protected Operation NOT Performed
6ļøā£ JWT vs Session-Based Authentication
This also raises an architectural question.
| Approach | Token Revocation | Replay Protection | Complexity |
|---|---|---|---|
| Long-lived JWT | Hard | Weak | Low |
| Short-lived JWT | Better | Better | Medium |
| JWT + Server-side Session | Strong | Strong | Medium |
| Opaque Session Token | Strong | Strong | Medium |
7ļøā£ Refresh Token Replay š
Another area I am particularly interested in is refresh-token reuse.
Refresh Token A
ā
Refresh Request
ā
Token A Invalidated
ā
Refresh Token B Issued
ā
Attacker Reuses Token A
ā
Replay Detected
ā
Reject / Terminate Session
What is the recommended production approach for detecting and handling this type of refresh-token replay?
8ļøā£ My Questions to the Community ā
- What is the recommended architecture for preventing JWT replay/token reuse after logout or session termination?
- Is JWT alone appropriate when immediate token invalidation is required?
- Should access tokens be short-lived with refresh-token rotation?
- What is the recommended way to invalidate previously issued access tokens?
- How should a backend detect and handle refresh-token replay?
- Would opaque/session-based tokens be a better alternative when strong revocation is required?
- From a penetration-testing perspective, what is the standard remediation when a previously issued token can still be reused?
- If the backend correctly returns 401 but Burp changes it to 200 before it reaches React, is there an accepted way to prevent the frontend from trusting the manipulated response?
9ļøā£ The Important Distinction
I understand that these are two different scenarios:
Scenario A ā Response Manipulation
Backend
ā
401 Unauthorized
ā
Burp Suite
ā
401 ā 200
ā
React
This may fool the client-side UI, because the browser is controlled by the attacker.
Scenario B ā Actual Authorization Bypass šØ
Expired / Revoked Token
ā
Protected API
ā
Backend Accepts Request
ā
Unauthorized Operation Executed
My primary concern is Scenario B.
Even if an attacker can manipulate the frontend or HTTP response, the backend should remain the final security boundary and must never perform an unauthorized operation.
š What I Am Looking For
I would particularly appreciate feedback from people who have:
- š”ļø Handled penetration-testing findings
- š Designed authentication/session architectures
- ā Implemented Spring Security
- āļø Secured React applications
- š¢ Built authentication systems for production applications
Iām interested in real-world solutions and architecture patterns, rather than only theoretical recommendations.
Tech Stack: āļø React + ā Spring Boot + š JWT
Would appreciate any practical recommendations, security standards, or real-world experience with this type of security finding. š
š¬ Final Question
How would you design the authentication and authorization architecture so that a captured, expired, revoked, or previously terminated token can never be reused to perform a protected operation ā even when the attacker controls the browser and uses Burp Suite to manipulate the HTTP traffic?
Top comments (0)