Skip to content

Change the default implementation of Saml2AuthenticationRequestRepository to store and load AuthnRequests based on the ID instead of the session #14013

Closed
@kailash-everlaw

Description

@kailash-everlaw

Expected Behavior
Saml2AuthenticationRequestRepository is implemented in a way that allows setting SameSite to Lax or Strict on the session cookie when using spring-security’s SAML implementation and spring-session.

Current Behavior
HttpSessionSaml2AuthenticationRequestRepository is the current default implementation of Saml2AuthenticationRequestRepository and uses HttpSession to store and load Requests, which means that the session cookie must have SameSite set to None since it must be included in the POST request sent by the user’s IdP.

Context
We currently have to set SameSite to None on the session cookie, which is not ideal since it weakens our defense against CSRF attacks. Ideally we would be able to set SameSite to Lax or Strict, but that is not currently possible due to how HttpSessionSaml2AuthenticationRequestRepository is implemented.

One possible workaround is to create a custom implementation of Saml2AuthenticationRequestRepository that stores and loads the Requests based on the ID instead of the session (as described in #10828 (comment) and #11468). However, I think it would be useful to make this the default implementation so that anyone who is using spring-security’s SAML implementation and spring-session can set SameSite to Lax or Strict on the session cookie without needing to create a custom implementation of Saml2AuthenticationRequestRepository. This new default behavior would be more secure than the existing default implementation, which requires SameSite to be set to None.

This is pretty similar to #11468, but I thought it made sense to open a new issue since that issue is closed and was focused on enabling this workaround, while this issue is about making the workaround enabled by that issue the default behavior.

I think it also might be possible to create an implementation of Saml2AuthenticationRequestRepository that loads and stores Requests using a custom cookie (as opposed to the session cookie), which would still allow SameSite to be set to Lax or Strict on that actual session cookie since it wouldn't need to be included in the POST from the user's IdP. I am not sure which approach is preferable though.

Metadata

Metadata

Assignees

Labels

in: saml2An issue in SAML2 modulesstatus: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions