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

Abandon cookie as session storage for v2.0.0 #275

Open
peppelinux opened this issue May 22, 2021 · 15 comments
Open

Abandon cookie as session storage for v2.0.0 #275

peppelinux opened this issue May 22, 2021 · 15 comments

Comments

@peppelinux
Copy link
Member

peppelinux commented May 22, 2021

Due to the latest cookie restrictions made by modern web browser, eg: samesite cookie, I'm wondering if it were time to rewrite entirely the session backend used to store SAML2 requests.

Here we have how djangosaml2 handles the persistence, in saml_session cookie:

class IdentityCache(Cache):

I'd abadon cookie storage and move to a DB storage (RDBMS or NoSQL). The SAML2 requests alwasy come with an ID and this will be involved in lookup. This will also introduce a stronger replay attack prevention strategy, based on parsing and matching the SAML2 request on all those already stored, nothing else.

In each stored saml2 request there will be a link to user that have been authenticated with it and also the SAML2 response as evidence of that.
They would have an expiration time equal to the corrisponding SAML2 NotOnOrAfter condition and it would be periodically purged (scheduled or NoSQL strategy like Redis TTL).

see also
https://github.com/WICG/WebID/blob/main/cookies.md

@peppelinux peppelinux added this to the 2.0.0 milestone May 22, 2021
@peppelinux peppelinux changed the title Definitely abadon cokkie session storage for v2.0.0 Definitely abadon cookie session storage for v2.0.0 May 22, 2021
@c00kiemon5ter c00kiemon5ter changed the title Definitely abadon cookie session storage for v2.0.0 Abandon cookie as session storage for v2.0.0 May 25, 2021
@rvanlaar
Copy link

Hey,
We're experiencing problems due to the cache being tied to cookies. I.e. sometimes the session cookie goes AWOL between us setting them and the user coming back with the credentials.

What kind of help do you want?

@peppelinux
Copy link
Member Author

in which conditions the AWOL occurs?

@rvanlaar
Copy link

in which conditions the AWOL occurs?

We haven't seen a common cause. It happens on all browsers on all platforms except of course the ones we test with.

Regarding help: This ticket has the label 'help wanted'. What kind of help do you want?

@peppelinux
Copy link
Member Author

Do you have configured the samesite cookie?
Which hostname do you use for tests (that work)?

Help wanted -> tests and answers are needed

@rvanlaar
Copy link

rvanlaar commented Nov 15, 2022

set-cookie: saml_session=LONGSTRING; HttpOnly; Path=/; SameSite=None; Secure

A lot of people are able to login. It's only some whom get the error 'UnsolicitedResponse'.

edit removed '<' '>' around LONGSTRING to get it to show.

@peppelinux
Copy link
Member Author

it's something up to the users' user-agent

please ask to them the user-agent and its version

@rvanlaar
Copy link

Could you elaborate?
Are you saying it's the user-agent? Or that it's due to the browser used?

@peppelinux
Copy link
Member Author

user-agent, I mean the web browser used by users

@rvanlaar
Copy link

Most errors come from:

Chrome 105 - 107
Mobile safari: 15.6.1 & 16.0
Safari 15.6.1
Edge 106

Split evenly between windows, iOS and Mac.

@peppelinux
Copy link
Member Author

Doesn't its request have the saml2 cookie?

@rvanlaar
Copy link

Which request and which cookie exactly?

@peppelinux
Copy link
Member Author

peppelinux commented Nov 15, 2022

Saml2 Response issued by idp triggers a post http request submitted by user's web browser to your sp

In this request you should see the cookie your SP created previously, this links the Response to the request to the useragent, in your sp

@rvanlaar
Copy link

Logging shows the OutstandingQueriesCache is empty for users that encounter this problem.
If those users submit the cookie on post, that I don't know.

@dino8890
Copy link

in which conditions the AWOL occurs?

Hi, I can confirm we have the same issue with cookie going AWOL. Not sure of the cause either.

@peppelinux
Copy link
Member Author

The naive way to resolve this issue is enabling the unsolicited response in the SP but this lowers the security

If I were you I would investigate way the SP SAML SESSION cookie is not returned back to the SP when the HTTP POST happens from the IDP side to provide the Saml Response back to the SP

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

No branches or pull requests

3 participants