-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
pkce does not seem to work #1512
Comments
Is |
No, it was left at the default
I have tried the same setup with Okta and Cognito, they work like this out-of-the-box. I.e. code-grant and code_challenge. |
PKCE only makes sense in cases where no client secret can be used. You are using a client secret (hence the error message regarding client_secret_post). In that case, PKCE is useless and it’s even dangerous to be using client secrets in cases where you want PKCE.
However, we should throw a warning when PKCE is being used with a secret.
Try exchanging the auth code without a client secret snd it will work.
… On 6. Aug 2019, at 07:56, leo-baltus ***@***.***> wrote:
No, it was left at the default client_secret_basic. After setting it to none:
failed to get token: oauth2: cannot fetch token: 401 Unauthorized
Response: {"error":"invalid_client","error_description":"Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method)","error_hint":"The OAuth 2.0 Client supports client authentication method \"none\", but method \"client_secret_post\" was requested. You must configure the OAuth 2.0 client's \"token_endpoint_auth_method\" value to accept \"client_secret_post\".","status_code":401}
I have tried the same setup with Okta and Cognito, they work like this out-of-the-box. I.e. code-grant and code_challenge.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
For a public client, using a client secret obviously is not a wise thing to do. Im my case I am exploring PKCE in a private client so no issues with that, it might even enhance security. Maybe PKCE and public clients can be regarded as two separate things? That way all clients can benefit from PKCE. |
PKCE is a defensive measure against a scenario that can _only_ happen in a public scenario (mobile phone, desktop app). While using it with private clients on server side apps has no downside, it also has no upside (it does not improve security). However, using PKCE in a public scenario with a private client _is_ a security issue. Hence the idea of warning here.
… On 6. Aug 2019, at 09:14, leo-baltus ***@***.***> wrote:
For a public client, using a client secret obviously is not a wise thing to do. Im my case I am exploring PKCE in a private client so no issues with that, it might even enhance security.
Maybe PKCE and public clients can be regarded as two separate things? That way all clients can benefit from PKCE.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Consider the case of client behind a loadbalancer which does tls termination leaving the last part of the connection (LB to client) over plain http. I think a client could benefit from the extra measure. Hydra would also be on par with Okta, Cognito etc. |
If you have a MITM PKCE won’t do you any good. I’m sorry but that’s just not what PKCE does and that’s not how network security works and no hashed string will ever protect you from eavesdropping network connections.
Feel free to read the spec yourself if you do not trust us to make the right calls: https://tools.ietf.org/html/rfc7636
The people that wrote the spec (check the title for the public part) are pretty good at what they’re doing.
Hydra is not on par with Okta or Cognito. It excels both with better defensive mechanisms and real controls to keep you from making mistakes (like this one). I mean Okta uses security questions for recovering Admin Accounts (iCloud hacks anyone?). Hydra is more flexible, faster, more lightweight and open source.
… On 6. Aug 2019, at 09:32, leo-baltus ***@***.***> wrote:
Consider the case of client behind a loadbalancer which does tls termination leaving the last part of the connection (LB to client) over plain http. I think a client could benefit from the extra measure. Hydra would also be on par with Okta, Cognito etc.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Funny how https://tools.ietf.org/html/rfc7636 exactly specifies my example:
The outgoing connection is protected by TLS, so no MITM there. The incoming connection however is vulnerable to MITM but an attacker does not have the verifier to get the access token. |
No, the scenarios are completely separate. In the spec, the redirect url is not protected by TLS because it's using a custom redirect scheme (the only scenario where no TLS is allowed for Hydra). A malicious app can register on that scheme and receive the code BEFORE the legitimate app. In your scenario, there is no TLS connection between the LB and the server side app. A MITM could therefor listen in on all the traffic, including the result of the code exchange. We are going in circles and there is no productive outcome. I'll make a patch to address your initial issue (using PKCE should throw an error when a private client is being used) but that's as much time as I can dedicate to discuss this. |
We may be talking about different technologies but a LB is different from e.g. VPN, only incoming connections are proxied the client so outgoing calls are initiated over separate connections making their own tls handshake so code exchange is not going through the loadbalancers. |
In that case you still need the client secret (not known to the attacker) to exchange the code. Again, this attack only makes sense in the case where the client can not keep a secret confidential - mobile apps, desktop apps, and so on. |
Again, these are separate concerns. A public client cannot keep a client secret because it is a public client. A private client can be vulnerable to code hijacking if its incoming requests is not protected by TLS. They both can benefit from PKCE. In fact I do not see why modern private clients would not use PKCE in all cases. |
Private clients are not vulnerable to code hijacking because the hijacker does not have the client secret, which is required for the exchanging the code for the token. PKCE is a substitute for the client secret. Period. |
Using PKCE with private clients now returns an error message. Closes #1512
Using PKCE with private clients now returns an error message. Closes #1512
https://tools.ietf.org/html/draft-ietf-oauth-security-topics-09#section-2.1.1
|
Sorry, completely overlooked this :) Thank you for digging this up! Will change behavior accordingly! |
Yes, even if it is recommended for maximum security to implement PKCE on all platforms. It requires currently some iframe hacks to manage correctly local redirect management within the same context between parent and child iframe (it is annoying for those who implemented correctly CSPv2, to reduce our CSP security (local references) just to implement PKCE in Web). |
Hi, In order to follow https://tools.ietf.org/html/draft-ietf-oauth-security-topics-09#section-2.1.1 recommendation we also want to enable PKCE on private clients. Is there already a timeline on when is this going to be available in Hydra @aeneasr? Thanks a lot |
No timeline at the moment as we have iceboxed new features on our end for the next two months. However, we'd love a PR - you can probably work along the lines of: ory/fosite#375 |
Thank you for your quick answer. We will see if we can manage to do it ourselves or not |
We fixed it in fosite here: ory/fosite#382 |
Describe the bug
Running hydra v1.0.0 with a postgresql backend, its seems that
code_challenge_method
,code_challenge
andcode_verifier
are ignored, as it does not make any difference how right or wrong it is used.Reproducing the bug
This should be a valid challenge, the resulting code-to-access-token exchange is always sucessfull no matter how wrong my
code_verifier
is.Also setting e.g.
code_challenge_method=S257
does not result in some form of error.Server logs
logs showing how S257 is allowed:
Server configuration
Expected behavior
I expected an error on getting the accesstoken using a false
code_verifier
Also I expect errors when using unsupported
code_challenge_method
or too shortcode_challenge
'sEnvironment
Docker/kubernetes
The text was updated successfully, but these errors were encountered: