-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Summary
During security testing, it was discovered that the server validates JWT signatures against all configured keys regardless of the kid (key ID) in the token header. Tokens with an unknown or mismatched kid are accepted if the signature matches any configured key.
Current Behavior
- Token is created with
kid: "unknown-key-id-12345"in the header - Token is signed with the primary key
- Server accepts the token because it validates against all keys, ignoring the
kidheader
Expected Behavior
When a token includes a kid header, the server should:
- Look up the key with that specific
kid - Validate the signature only against that key
- Reject the token if the
kiddoesn't match any known key
Security Impact
Medium: This behavior means:
- Attackers cannot exploit this to bypass authentication (signatures are still validated)
- However, it reduces the effectiveness of key rotation
- If a key is compromised and rotated out, old tokens might still validate if signed with a remaining key
Technical Details
- Location: JWT signature validation in
JsonWebKeysProvider/ Micronaut Security - Test Reference:
SecurityEdgeCasesTest.tokenWithUnknownKeyId_documentsKeyIdBehavior() - Current Implementation: Server tries all keys from the JWK set
Suggested Fix
Configure Micronaut's JWT signature validation to:
- Use the
kidheader to select the appropriate key - Fall back to trying all keys only if
kidis not present - Reject tokens with unknown
kidvalues
Labels
- security
- enhancement
Metadata
Metadata
Assignees
Labels
No labels