spring-projects / spring-projects/spring-security

Infinite redirect loop when invalid url is requested with remember me user and session timed out

Open
#5,404 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
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
  1. User logs in with remember me
  2. After 30 minutes the session times out
  3. An invalid URL is requested (e.g. localhost:8080/invalidurl)
  4. remember-me token detected and accepted in filter chain
  5. AccessDeniedException is thrown due to bad URL
  6. ExceptionTranslationFilter handles exception. With authenticationTrustResolver.isRememberMe(authentication) true, exception is handled with call to sendStartAuthentication
  7. The Authentication entry point is called, and remember-me token is detected and accepted again in the filter chain populating the SecurityContextHolder
  8. A redirect to the invalid URL saved in the DefaultSavedRequest is executed
  9. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.