-
Notifications
You must be signed in to change notification settings - Fork 398
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
Option to enforce algorithm matching between JWT and JWK #356
Comments
I think this would be reasonable to enforce by default. For what it's worth, we do enforce based on what the provider advertises it supports, just not on a per-key basis: Lines 123 to 133 in fb9e009
|
Thanks - I'm familiar with the provider-level enforcement, and agree it's sufficient in the majority of use cases. |
Out of curiosity, have you brought this up with the go-jose package? They should have all the information they need to detect that an signature's alg value doesn't match the key's alg value. |
I was on the fence about whether this was a key matching concern versus a verification concern, and landed on key matching. I'm open to directing this to go-jose if you think that makes more sense. |
Just to try to be very clear about the security concerns here. Say we have Key A that advertises RS256 and Key B that advertises RS384.
Given that:
|
go-jose v2 is not actively developed anymore. Maybe go-oidc should consider migrating to v3 or to a more actively maintained library, such as jwx, the maintainer, @lestrrat is very responsive. I'm not sure if jwx already does this check |
Thanks! I've updated the import for go-jose #360 Again, I do think this check should be in the go-jose package. |
In an environment where multiple varieties of a key type are supported (e.g. RS256 and RS384), the library doesn't enforce that the algorithm specified in the keyset for the kid specified in the JWT matches the algorithm specified in the JWT.
The go-jose library does ensure that the JWT is verified using the same algorithm family (e.g. using an rsaEncrypterVerifier), but uses the algorithm defined on the JWT.
Example:
jwks defines two keys:
{ "kty": "RSA", "use": "sig", "kid": "kid256", "alg": "RS256", "n": "...", "e": "...", }
{ "kty": "RSA", "use": "sig", "kid": "kid384", "alg": "RS384", "n": "...", "e": "...", }
Client generates an RS256 JWT using the private key associated with kid384, with header:
{ "kid": "kid384", "typ": "JWT", "alg": "RS256" }
This is successfully validated:
I'm unclear on the risk (if any) associated with this type of substitution, but it would be useful to have an option to enforce JWT and key algorithm matching when that's the intended usage.
The text was updated successfully, but these errors were encountered: