4 ms·
That whole section is about the implicit grant anyway, which should be avoided. As far as validating tokens, access tokens are 'opaque' in OAuth2; the token fo
by mooreds 6y ago
That whole section is about the implicit grant anyway, which should be avoided.
As far as validating tokens, access tokens are 'opaque' in OAuth2; the token format is not defined by the spec. (In OIDC, they are JSON web tokens.) For OAuth, you can make a call to the introspect endpoint and the Authorization Server will tell you if it is a valid token.
In practice, OAuth servers often issue JWTs, and there's a draft spec out to make them interoperable: https://tools.ietf.org/html/draft-ietf-oauth-access-token-jwt-11 https://tools.ietf.org/html/draft-ietf-oauth-access-token-jw...
If you are a resource server consuming an access token and you know the token is a JWT, you should check the following at a minimum:
* the token is signed according to the algo and the key that you expect
* the token is not expired (the `exp` claim) and is currently valid (the `nbf` claim, if present)
* the token is issued by who you expect (the `iss` claim) (which is the point you are making about 'trusted providers')
* the token is issued for you (the `aud` claim)
Most libraries I have interacted with check the first two, but not the last two.
- progre 6y agoI didn't know the token format wasn't specified, thanks for the clarification! I've only ever come across JWT:s.
- cratermoon 6y ago> the token is signed according to the algo and the key that you expect Important point! Especially with JWT. It must be the algorithm you EXPECT, not the algorithm in the token. Someone flubbed up and made the "none" algorithm mandatory for spec-compliant implementations. Unfortunately, that can result in any JWT being treated as valid. It's a chicken-and-egg problem that the designers missed: you can't trust the token until you've validated it, but you'd have to believe the value of the algo field before you've validated it in order to check the signature. There are libraries that will see "none" in the algo field and treat that as "this token doesn't have a signature that needs to be validated, so it's good".
- mooreds 6y ago> Someone flubbed up and made the "none" algorithm mandatory for spec-compliant implementations. Which spec are you referring to? 7519? Per section 6 ( https://tools.ietf.org/html/rfc7519#section-6 https://tools.ietf.org/html/rfc7519#section-6 ) "none" is an optional feature of JWT. I am not aware of any spec related to OAuth which requires a server to issue or accept a JWT with an algo of "none". Can you point one out to me? From the AS side, our product won't even allow you to "sign" a JWT with a value of none. I'm not sure about other authorization servers. And I always recommend that if a resource server ever sees an algorithm of "none" it should throw out the JWT full stop. > It's a chicken-and-egg problem that the designers missed: you can't trust the token until you've validated it, but you'd have to believe the value of the algo field before you've validated it in order to check the signature. What is the way around this? Looks like Paseto tokens (an alternative I've heard mentioned) works by not allowing unsigned tokens: https://github.com/paragonie/paseto https://github.com/paragonie/paseto Is there another way to fix this? > There are libraries that will see "none" in the algo field and treat that as "this token doesn't have a signature that needs to be validated, so it's good". Spooky! Can you share these so I can stay far away from them? :)
- cratermoon 6y ago> Which spec are you referring to? OK, this one's on me. I can't find the reference, and I took an article at face value: https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries https://auth0.com/blog/critical-vulnerabilities-in-json-web-... There are libraries that allow Bad Things, though, and best practice now is just to ignore the `alg` field. As the github repo you linked says, "There have been ways to exploit JWT libraries by replacing RS256 with HS256 and using the known public key as the HMAC-SHA256 key, thereby allowing arbitrary token forgery."
- eyelidlessness 6y ago> the token is issued for you (the `aud` claim) My goodness I wish I was allowed to disclose a place where this was used for privilege escalation and not checked in any way.
- hirsin 6y agoUnencrypted, client legible access tokens is probably one of the worst ecosystem mistakes you can make. It lets devs (like the article author) read oauth as oauthN "because I can read the token". So now you have clients taking a silent dependency in your ecosystem on being able to predictably read the access token, even though they're not the audience. Suddenly, decisions like "change the format of the token for this resource" or "let's start encrypting" become ecosystem shattering projects. Encrypt your access tokens by default if you want to guarantee clever clients don't try to take a dependency on them.
- dwaite 6y agoIt is a conflation of the access token (message to the protected resources about the client) and the identity token (message to the client about the user). OAuth doesn't define the concept of an identity token, hence it not being usable itself for authentication OpenID Connect extends OAuth with an identity token, which is of course readable by the client. To be fair, Facebook Connect explicitly made this choice to combine the identity token into the access token - so their access token is necessarily client-readable and verifiable.
- hirsin 6y agoYes, indeed :-)