What should be the defaults for ResponseType for OIDC
The current default is IdToken + Code. However, this requires the client secret to redeem the Code. This is problematic for some of the templates.
The current recommendation is to override the defaults in the template to IdToken and then followup on fixing the tooling so it can use the normal default IdToken + Code. No changes are recommended for the Security repo.
@rustd Please move this to the correct tooling repo. @phenning
https://github.com/aspnet/Templates/issues/445 is tracking this
The current recommendation is to override the defaults in the template to IdToken and then followup on fixing the tooling so it can use the normal default IdToken + Code. No changes are recommended for the Security repo.
The code flow is much safer compared to the other flows, specially since it prevents the user agent from accessing the access token or the identity token.
IMHO, it should be the default flow.
Hybrid flow is the most secure default - so code id_token.
@leastprivilege not sure to understand why or how, as the code flow never leaks tokens as it exclusively uses backchannel communication and is the only one that can be used with any response_mode, including query.
The only thing the hybrid flow usually mitigates is unwanted token requests made to the identity provider, but it only works if the OIDC client implements anti-replay countermeasures (using nonce), which is not true with the OIDC middleware by default (currently, absolutely nothing prevents me from replaying the callback request 1000 times to make the OIDC middleware send 1000 token requests if I want to).
To quote Nat from the OpenID foundation:
It so happens that the hybrid flow is the most secure way. The the front channel through the user agent is an untrusted transport. Adversary can tamper the response and do bad things. To prevent it, you need a signature on the response to detect it. ID Token works as the detached signature so if you use the hybrid flow, you will be able to tell if the front channel payload has been tampered with or replaced by adversary.
What he is talking about is e.g. the so called "code cut n paste" attack where an attacker can replace his own code with a stolen one. In general the id token provides a verifiable signature over the artefacts that get transported over the front channel (the c_hash claim). That's why.
Are you saying the the OIDC MW does not validate the nonce?? Isn't that required? That should be implemented.
Added: http://nat.sakimura.org/2016/01/25/cut-and-pasted-code-attack-in-oauth-2-0-rfc6749/ @vibronet
I agree the code replacement attack is a serious threat (that's why I was opposed to enabling ShareCallbackPath by default: https://github.com/aspnet/Security/pull/653#issuecomment-173655710), but I don't see how using the hybrid flow mitigates it.
If I can steal a code, I can also likely steal the corresponding id_token and send them both using my own machine (the only practical limit is the nonce, that must correspond to the original value initially sent in the authorization request, but it's easy to bypass if the attacker makes sure the victim is redirected to the identity provider with a nonce he controls).
Are you saying the the OIDC MW does not validate the nonce?? Isn't that required? That should be implemented.
No, I'm saying that the way it's currently implemented can't prevent this kind of attacks, as the nonce is not stored in a database but in a client cookie. You can read this thread for more info: https://github.com/aspnet/Security/pull/446#issuecomment-139686806.
So coming back to the original thread - if there should be one default response type (especially for the templates) - then plain id_token is the easiest and most secure (same threat model as a WS-Fed signin - and no need for a client secret).
Once an access token is involved - hybrid (with nonce storage in a protected cookie + checking and short lived id tokens) provides the most mitigation techniques for todays known attacks.
I know this was already clodes, but I concur with @leastprivilege - a good default for the MW would be id_token.
Reopening. The current recommendation is to change the middleware to default to id_token.
Why not an "hybrid" approach?
response_type could default to id_token if client_secret is missing, code id_token if it's not.
magic interdependent properties? :cry:
Oh yea, no magic please.
Well, it's a compromise, not an ideal proposal :trollface:
I'm still 100% convinced that confidential clients - like server-side apps - should use the code flow, as mentioned by the OIDC spec:
The Authorization Code Flow returns an Authorization Code to the Client, which can then exchange it for an ID Token and an Access Token directly. This provides the benefit of not exposing any tokens to the User Agent and possibly other malicious applications with access to the User Agent. The Authorization Server can also authenticate the Client before exchanging the Authorization Code for an Access Token. The Authorization Code flow is suitable for Clients that can securely maintain a Client Secret between themselves and the Authorization Server.
http://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth
The Implicit Flow is mainly used by Clients implemented in a browser using a scripting language. The Access Token and ID Token are returned directly to the Client, which may expose them to the End-User and applications that have access to the End-User's User Agent. The Authorization Server does not perform Client Authentication.
http://openid.net/specs/openid-connect-core-1_0.html#ImplicitFlowAuth
Changed to IdToken in dev and release.