-
Notifications
You must be signed in to change notification settings - Fork 6k
Change the default implementation of Saml2AuthenticationRequestRepository to store and load AuthnRequests based on the ID instead of the session #14013
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
Comments
Stumbled upon this because we're actually using the legacy Spring Security SAML library still and I was curious how this is handled in new versions (appears to still be an issue essentially). FWIW this "half works" currently with
We were sort of exploring the last option in your paragraph which is a different cookie just for this purpose that could then be set to |
Thanks for the suggestion, @kailash-everlaw. It may make sense to provide an implementation that does not retrieve the authentication request from the session. That said, it's important to remember that there are security benefits to storing it in the session. One such benefit is the natural login fixation defense it provides. For example, if an application looks the authentication request up from the session, then even if an attacker provides their own SAML response to a victim, the login will fail. On the other hand, if we trust the Given that, I'd argue that using As for this ticket, I think for Spring Security to provide a by-id implementation is too early due to what I outlined above. That said, I don't mind taking a look at this ticket again once #14297 is resolved. |
@jzheaux Thanks for the response!
Just to confirm I'm understanding correctly, are you saying that after the SAML request is sent but before the legitimate SAML response is received an attacker could send a spoofed SAML response and use that to login?
Assuming I'm understanding the security implications correctly, this makes sense to me. This is kind of what I had in mind when I mentioned using two different cookies - it seemed like a simple way for the pre and post-authentication cookies to have different
FWIW my main motivation behind opening this was to try to find a way for the post-authentication cookie to be |
Not quite. I'm saying that an attacker could begin a legitimate login of their own, intercept the redirect, and use that to force a victim's browser to log in as the attacker. It is a traditional fixation attack, similar to session fixation attacks where an attacker can log in legitimately and then provide a URL to a victim that contains the attacker's session id.
Sounds good, I'll close this issue for now. We can always reopen if we need to take another look. |
Interesting, thanks for explaining that! |
Expected Behavior
Saml2AuthenticationRequestRepository
is implemented in a way that allows settingSameSite
toLax
orStrict
on the session cookie when using spring-security’s SAML implementation and spring-session.Current Behavior
HttpSessionSaml2AuthenticationRequestRepository
is the current default implementation ofSaml2AuthenticationRequestRepository
and usesHttpSession
to store and load Requests, which means that the session cookie must haveSameSite
set toNone
since it must be included in thePOST
request sent by the user’s IdP.Context
We currently have to set
SameSite
toNone
on the session cookie, which is not ideal since it weakens our defense against CSRF attacks. Ideally we would be able to setSameSite
toLax
orStrict
, but that is not currently possible due to howHttpSessionSaml2AuthenticationRequestRepository
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 setSameSite
toLax
orStrict
on the session cookie without needing to create a custom implementation ofSaml2AuthenticationRequestRepository
. This new default behavior would be more secure than the existing default implementation, which requiresSameSite
to be set toNone
.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 allowSameSite
to be set toLax
orStrict
on that actual session cookie since it wouldn't need to be included in thePOST
from the user's IdP. I am not sure which approach is preferable though.The text was updated successfully, but these errors were encountered: