spring-projects / spring-projects/spring-security
SEC-2427: Subsequent requests from the same browser break remember me function and throws CookieTheftException
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Vertonur Sunimi (Migrated from SEC-2427) said:
Prerequisite: Browser with authenticated rememberme cookie stored.
Reproduction steps:
- The browser open a page to trigger auto login.
- Request received by server and processed right before code tokenRepository.updateToken(newToken.getSeries(), newToken.getTokenValue(), newToken.getDate()); of PersistentTokenBasedRememberMeServices and the executing thread paused.
- End user refresh the page and a second request is sent to the server
- The second request is recieved and processed through the Spring Security filters and returned a new cookie to the browser and the token( token-A) in the db is updated either.
- The first request resumed and run code updateToken thus the db is updated with the new generated token (token-B). As the request has been canceled by the browser so token-B will never reach the browser with code addCookie(newToken, request, response);
- Session of the end user time out and pages are requested again, browser send request s with token-A
- !presentedToken.equals(token.getTokenValue()) of PersistentTokenBasedRememberMeServices is checked thus caused CookieTheftException be thrown and all tokens related to the end user in db are deleted.
SO concurrency control is needed for rememberme filter.
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 in PersistentTokenBasedRememberMeServices at the tokenRepository.updateToken and addCookie calls described in the reproduction. Recreate the two overlapping auto-login requests, including the canceled first response, and inspect how token-A and token-B are persisted. Done means the concurrent sequence no longer causes CookieTheftException or deletes the user's remember-me tokens.
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