spring-projects / spring-projects/spring-security
Infinite redirect loop when invalid url is requested with remember me user and session timed out
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Summary
If a user is authenticated with remember me, and the session times out after the default 30 minutes, then when an invalid URL is requested, an infinite redirect loop occurs in the handling of the AccessDeniedException.
Actual Behavior
- User logs in with remember me
- After 30 minutes the session times out
- An invalid URL is requested (e.g. localhost:8080/invalidurl)
- remember-me token detected and accepted in filter chain
- AccessDeniedException is thrown due to bad URL
ExceptionTranslationFilterhandles exception. WithauthenticationTrustResolver.isRememberMe(authentication)true, exception is handled with call tosendStartAuthentication- The Authentication entry point is called, and remember-me token is detected and accepted again in the filter chain populating the
SecurityContextHolder - A redirect to the invalid URL saved in the DefaultSavedRequest is executed
- Go to Step 5 (infinite loop)
Expected Behavior
When the session is still valid with a remember me user, an invalid URL is handled by the accessDeniedHandler in the ExceptionTranslationFilter. The expected default behavior would be the same when the session is timed out after 30 minutes.
Version
4.2.4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the ExceptionTranslationFilter, authenticationTrustResolver, sendStartAuthentication, and DefaultSavedRequest paths described in the report. Reproduce the remember-me timeout and invalid-URL sequence, then verify that the accessDeniedHandler handles the request without redirecting back into the loop.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100