-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
SignatureException could include the header and claims #969
Comments
Hi @mnylensc , is someone looking into it ?? If not can I take it up ? |
Personally, I'd be very cautious about adding this to JJWT, as mentioned above it is potentially dangerous. Or maybe, make it possible for a user to do the dangerous bits themselves easier. Again, personally I'm reluctant, but I'd still be interested in other thoughts on where a |
Hi @bdemers, consider the below case,
Is this understanding (regarding the danger associated with this feature) correct ? or I'm thinking in the wrong direction 🤔💭 Hey @mnylen, I want to understand how could a header be useful in logging and secondly the developer team would be knowing the header details and it would probably be same for all the granted/generated tokens. Coming to the payload, what if we could add some logic to log only selective claims instead of all of the claims 🫥. |
I think the danger here is that someone would catch the Consider the following:
Nobody should write code like this, but it's still a mistake that can be made, and someone will eventually end up making it... However, similar mistake can be already be made with Edit: And of course, there are myriad other ways that using claims from an unverified tokens can cause. Some other possible scenarios that popped into my head:
|
However, these dangers I listed above are imo more about the claims. I don't know why I suggested it originally, because the implementation should not even try parsing the claims if the signature verification failed. For the header, I don't see similar risks (although, arguably, one can include custom non-standard header fields). The parser anyway needs to parse the header to verify the JWT signature, because the header is needed for locating the key. Having |
@mnylensc the use case regarding metrics collection with 'kid' sounds a good measure to track the SignatureExceptions in case we have multiple options for kid. If I'm not mistaken, this 'kid' identifier can be different in same environment because of specific implementation or be different because of different environment specific keys. Please add if I'm missing something here. Thanks |
Actually, this feature makes sense. In my case jws token is provided by identity & access management proxy server. It is completely safe and there is no need for further verification |
Is your feature request related to a problem? Please describe.
If
JwtParser#parseSignedClaims
call results intoSignatureException
, it's not possible to parse the JWS header or claims from the exception. This would be useful for collecting metrics per key id and audit logging, when you could log the already parsed header and claims.Describe the solution you'd like
Similar to
ExpiredJwtException#getHeader()
and#getClaims()
,SignatureException
could also have those methods.I realize the methods are missing probably because this could be quite dangerous if used wrong, but maybe the methods could be named with
dangerously
prefix to signify the inherent danger in using the return values...?Describe alternatives you've considered
Decoding the JWS parts myself, but this seems like a waste, when the work to parse the token has already been done by JJWT.
Additional context
JJWT version 0.12.6
The text was updated successfully, but these errors were encountered: