spring-projects / spring-projects/spring-security

Session Control does not work properly when race condition happens

Open
#18,155 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: bug
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Describe the bug
When login is performed by the same user multiple times from different internet browsers / devices, login can be performed successfully despite setting only 1 max session.

To Reproduce
Have the following code in the SecurityFilterChain

http.sessionManagement(sessionManagement -> {
      sessionManagement.maximumSessions(1);
    });

and when the race condition happens, the session count is 2 despite the above setting.

Image

Expected behavior
Only the last login session should persist, all other sessions should be terminated.

Sample
I've done up a sample here.
Start the Spring Boot Application by the using the java class SecuringWebApplication.java
https://github.com/samueljz/spring-concurrency-issue/tree/main/complete

Race conditions can be introduced using tools such as Burp Suite.

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 with the sample application's SecuringWebApplication.java and its SecurityFilterChain, then reproduce concurrent logins with maximumSessions(1), using the reported race-condition setup if available. Trace the session-control behavior during simultaneous logins; done means only the last login session persists and the session count does not exceed one.

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.