Skip to content
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

NPE thrown when JWKs verification fails and log level is DEBUG #1839

Closed
OKenyonNexthink opened this issue Nov 1, 2024 · 0 comments · Fixed by #1858
Closed

NPE thrown when JWKs verification fails and log level is DEBUG #1839

OKenyonNexthink opened this issue Nov 1, 2024 · 0 comments · Fixed by #1858
Assignees

Comments

@OKenyonNexthink
Copy link

Expected Behavior

The code should probably check that JWK::getAlgorithm does not return null

Actual Behaviour

NPE is thrown here: https://github.com/micronaut-projects/micronaut-security/blob/4.11.x/security-jwt/src/main/java/io/micronaut/security/token/jwt/signature/jwks/JwksSignatureUtils.java#L109

Steps To Reproduce

Try to verify a token which is not valid using a public key which does not have an algorithm specified, with log level set to DEBUG.

The call from here:

LOG.debug("JWT Signature algorithm {} not supported by JWK Set. {} ", jwt.getHeader().getAlgorithm(), JwksSignatureUtils.supportedAlgorithmsMessage(jwkSet));

to here: https://github.com/micronaut-projects/micronaut-security/blob/4.11.x/security-jwt/src/main/java/io/micronaut/security/token/jwt/signature/jwks/JwksSignatureUtils.java#L109

results in NPE as algorithm is not checked for null. According to RFC, I think it's allowed to be null, so maybe Micronaut should add a check to cover this? https://datatracker.ietf.org/doc/html/rfc7517#section-4.4

Environment Information

Linux/MacOS and Java 21

Example Application

No response

Version

4.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants