Skip to content

REF-30: Change the session id when a login is accepted - #97

Merged
thomasnymand merged 4 commits into
masterfrom
feature/REF-30-rotate-session-id-on-login
Aug 26, 2026
Merged

thomasnymand merged 4 commits into
masterfrom
feature/REF-30-rotate-session-id-on-login

Conversation

@thomasnymand

Copy link
Copy Markdown
Collaborator

Gives the session a new id when a login is accepted.

Problem

The validated assertion was stored on whatever session the browser already had. The container session id was never rotated across the authentication boundary, so an id present before login stayed valid as an authenticated session afterwards, which is what session fixation relies on.

Changes

  • AssertionHandler changes the session id once validation has passed and before the assertion is stored.
  • Session state is keyed on the container session id, so the in-flight AuthnRequest is stored again under the new id. Without that the session looks unauthenticated to AuthenticatedFilter and the user is sent straight back to the IdP.

Breaking: the library now requires Servlet 3.1

HttpServletRequest.changeSessionId() is Servlet 3.1, so javax.servlet-api goes from 3.0.1 to 3.1.0. Consumers on a Servlet 3.0 container will need to move to 3.1 or later; worth a line in RELEASE_NOTES.md at release time.

Consequences in this repository:

  • The demo ran on tomcat7-maven-plugin, which is Servlet 3.0. It now runs on jetty-maven-plugin 9.4 with the HTTPS connector configured in demo/src/main/jetty/jetty-https.xml, reading the existing misc/ssl-demo.pfx keystore. The run command is now mvn clean install followed by mvn -pl demo jetty:run-war, as documented in the README.
  • Three test stream stubs had to implement the methods Servlet 3.1 added to ServletInputStream and ServletOutputStream.

Verification

mvn -pl oiosaml test → 113 tests, 1 failure: the pre-existing OIOBPPUtilTest (JDK 26 JAXB incompatibility), which also fails on master.

The new test asserts the ordering: session id changed, AuthnRequest stored again, assertion stored. With AssertionHandler reverted it fails.

The demo was started on Jetty and checked over TLS: https://localhost:8443/oiosaml3-demo.java/ returns 200 and /saml/metadata serves the SP metadata.

Note that mvn install at the reactor level stops in the idp module. That failure is present on unmodified master as well and is unrelated to this change.

The validated assertion was stored on whatever session the browser already had.
The container session id was never rotated across the authentication boundary,
so an id present before login stayed valid as an authenticated session
afterwards, which is what session fixation relies on.

AssertionHandler now changes the session id once validation has passed and
before the assertion is stored. Session state is keyed on the container session
id, so the in-flight AuthnRequest is stored again under the new id, otherwise
the session would look unauthenticated to AuthenticatedFilter and the user
would be sent straight back to the IdP.

changeSessionId() is Servlet 3.1, so javax.servlet-api goes from 3.0.1 to
3.1.0 and the library now requires a Servlet 3.1 container, which the README
states. The demo ran on the tomcat7 plugin, Servlet 3.0, and now runs on the
jetty-maven-plugin with the HTTPS connector configured in
demo/src/main/jetty/jetty-https.xml. Verified by starting the demo and fetching
the front page and the SP metadata over https://localhost:8443.

Two test stream stubs had to implement the methods Servlet 3.1 added to
ServletInputStream and ServletOutputStream.

Tested by asserting the order in AssertionHandler: session id changed,
AuthnRequest stored again, assertion stored.
@thomasnymand
thomasnymand requested a review from mthiim August 18, 2026 08:25
@thomasnymand
thomasnymand merged commit 0777627 into master Aug 26, 2026
2 checks passed
@thomasnymand
thomasnymand deleted the feature/REF-30-rotate-session-id-on-login branch August 26, 2026 18:29
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

Successfully merging this pull request may close these issues.

2 participants