Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sessions map entries not removing when session-fixation-protection is "migrateSession" #72

Open
boroda4436 opened this issue Apr 25, 2019 · 0 comments

Comments

@boroda4436
Copy link

Faced with the problem that sessions map is not cleaning completely when sessions expire.
Looks like issue is not resolved completely.

In the debug mode I am able to see that original session in the hz session is invalid, but is still present in the sessions ConcurrentHashMap:

((Session)((HazelcastHttpSession)((java.util.concurrent.ConcurrentHashMap.MapEntry)sessions.entrySet().toArray()[0]).getValue()).originalSession)._state == INVALID

in this case
private final ConcurrentMap<String, HazelcastHttpSession> sessions = new ConcurrentHashMap(1000)
will grow in the size and will cause memory leak.

The requests with basic auth hit this method (after successful basic authentication):

`
package org.springframework.security.web.authentication.session;

abstract class AbstractSessionFixationProtectionStrategy implements
SessionAuthenticationStrategy, ApplicationEventPublisherAware {
...
/**
* Applies session fixation
*
* @param request the {@link HttpServletRequest} to apply session fixation protection
* for
* @return the new {@link HttpSession} to use. Cannot be null.
*/
abstract HttpSession applySessionFixation(HttpServletRequest request);
...
}
`
The method above is changing the session id, but the Hazelcast doesn’t know about it.
Hazelcast trying to remove the session based on the old session id, cannot find the session and that's why the session is not removing and memory leak occurs.

Conf:
<hazelcastVersion 3.8.3 /hazelcastVersion>
<springVersion 4.3.7.RELEASE springVersion>
<springSecurityVersion 4.2.3.RELEASE springSecurityVersion>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant