-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Spring Boot 2.3.x refuses JWT tokens with custom typ
header
#8730
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
Comments
This is my problem too. Since the IdentityServer4 uses “at+jwt” JWT typ. Token validation always fail. Good thing I have control in the IS4 and set its typ to “jwt” |
Thanks for the heads up, @jrehwaldt and @materia2021. While this could be solved by manually constructing a This isn't the first time that a desire to post-process the At that point, you could do: NimbusJwtDecoder jwtDecoder = withPublicKey(key)
.jwtProcessor(jwtProcessor -> jwtProcessor.setJWSTypeVerifier(...))
.build(); Can you confirm that this would resolve your issue? If so, would one of you be able to put together a PR to add a post-processor to each of the builders? |
@jzheaux I had the same thought. There is a catch, though: On a side note why I did not propose it: I was concerned one could somehow break the security by misconfiguring Nimbus, making it a risky extension. On the other hand, it is for advanced usage and people should have an idea what that are doing anyway 🤷♂️ |
@jrehwaldt I think if you have it pass a
It certainly does give the user more power, but it's no more power than they already have with the
Sounds great, @jrehwaldt. |
Uh oh!
There was an error while loading. Please reload this page.
Spring Boot 2.3.x.RELEASE applies additional non-standard validation on JWT tokens due to upgrade to NimbusDS 8.x.
With Spring Boot 2.2.2.RELEASE a JWT token with header field
typ: "JWS"
validates fine. In Spring Boot 2.3.0.RELEASE such a token is rejected due to a breaking change in NimbusDS 8.x, which requirestyp
to be set to eitherJWT
or omitted.As per RFC 7515 there's no dedicated
typ
mandated.The issue is that the builder design in
NimbusJwtDecoder
(in my caseNimbusJwtDecoder.withPublicKey(publicKey).build()
) does not allow to go back to the old behavior, nor does it allow to change theJWSTypeVerifier
/JWETypeVerifier
set in NimbusDS'sDefaultJWTProcessor
. Therefore, it is currently necessary to duplicate the complete builder code, which is making me uneasy considering it's a security relevant part and a future change in Spring Security/Nimbus might render my code insecure.Current Behavior
JWT tokens with
typ: JWS
are refused since Spring Boot 2.3.xExpected Behavior
Either one of:
Context
Dependency:
org.springframework.security:spring-security-oauth2-jose:5.3.3.RELEASE
Class:
org.springframework.security.oauth2.jwt.NimbusJwtDecoder
Unfortunately, I am not in control of the authorization server, which generates these custom JWTs. At the same time, I do not want to copy security relevant code.
Possible solutions:
JWSTypeVerifier
/JWETypeVerifier
to no-op verifiers in the builder(s)Stacktrace
The text was updated successfully, but these errors were encountered: