Description
Description
The out-of-the-box behavior is that unauthenticated calls trigger session creation but authenticated calls do NOT trigger session creation. This seems backwards.
An attacker may potentially consume a lot of server memory via sending malicious http requests to create an unbounded number of sessions, so there is potential for a DoS attack.
To Reproduce
This authenticates and returns 200 but does not create a session. Note in the logs "Failed to create a session, as response has been committed. Unable to store SecurityContext."
curl -kv --user admin:admin http://localhost:9000/login
Here, the first call creates an anonymous session and returns 401 (no credentials were passed) then passing the session id back on the second call associates that session with the username. It seems like out of the box authenticated session creation only works if we make a preflight request
curl -kv -b cookies.txt -c cookies.txt -X OPTIONS http://localhost:9000/login
curl -kv -b cookies.txt -c cookies.txt --user admin:admin http://localhost:9000/login
cat cookies.txt
Expected behavior
I expected that the default session creation policy be IF_REQUIRED instead of null (when it is IF_REQUIRED then we have the expected behavior of a session being created and saved upon successful authentication), and that unauthenticated calls would NOT have a session created.
Sample
Here is a link to a GitHub repository with a minimal, reproducible sample.