-
Notifications
You must be signed in to change notification settings - Fork 259
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
Cookie echoing with wrong path in provider.authz_part2 #398
Comments
Just noticed that this also strips the 'secure' Flag from cookies, so this is a security issue too. |
I have a very diffuse memory now about why I did it. It came from the OIDC test tool and if I remember correctly it was the only way I could get it working against a specific OIDC OP. |
Commenting out the code at |
Ok, if it echoes things exactly how it finds them, I'm fine with it. Only the 'wrong path/strip flags' part is not good. We had some similar issues with the need to echo Cookies with some Javascript inside Microsoft IE, which lost cookies in XHR requests sometimes. |
@tpazderka I have some integration tests with requests.Session against a whole OP, but not nicely isolated. Looking at the tests, i found that the whole echoing of cookies is dangerous and should be avoided, as you cannot really make it safe. A cookie can have various security properties set up in the Set-Cookie header, e.g. secure, httponly, samesite, domain and path. Those are NOT visible in the received cookies on the server side, e.g. the Cookie headers. This is spelled out in https://tools.ietf.org/html/rfc6265#section-5.4, the User Agent looks at the URI and computes the resulting Cookie string, stripping all the security attributes and turning it into a simple key-value list. As the server cannot safely decide which cookies are safe to echo, we should simply NEVER echo a cookie. A more complete integration test test goes like this:
This can be simulated by setting up a fake cookiejar with requests.Session() and running a login flow against the op with the same cookie jar. Just add some secure/httponly cookies and log the used domains/paths/flags. Like this (not complete):
|
OK, I do agree that handling of the cookies on our side should be better. Will try to look into it. |
When the oidc provider is not placed at the '/' path, e.g. putting it under '/oidc' instead, the code setting the SSO cookie in
self._complete_authz()
does a surprising thing: It echoes all cookies it receives with the current path.So for example, you have an app mounted at '/' that sets a cookie 'lang=en', path='/'. Now you run a oidc flow against a provider with baseurl '/oidc'.
The code now sees a cookie in
environ['HTTP_COOKIE']
from wsgi, extracts it viawsgi_wrapper
and puts as kwargs into the authorization endpoint. This does all the usual things, then descends toauthz_part2
, and passes the cookies into thecomplete_authz
in the baseclass. The code inspects all the cookies, then copies them into headers, so they get set again, but with a different path argument (/oidc).I do not understand why this cookie echoing is needed at all.
Can anyone shed some light into this, why is this needed in
oic.oauth2.provider.AProvider._complete_authz()
? And if your at it, why is very similar code commented out inoic.oic.provider
around line 789?Both have been introduced with 59f83ac by @rohe
The text was updated successfully, but these errors were encountered: