-
Notifications
You must be signed in to change notification settings - Fork 417
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
Validate size of signature against algorithm considering JWE #2008
Conversation
Seems like this also addresses #1743, is that correct? |
@TimHannMSFT had not considered #1743 |
My mistake, I think I got the key size check and the signature size check confused. In reply to: 1407145465 |
public class TamperedTokenTests | ||
{ | ||
[Theory, MemberData(nameof(JwtSignatureTruncationTheoryData))] | ||
public async Task JwtSignatureTruncation(ValidateTokenTheoryData theoryData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we're doing some similar testing in SignatureProviderTests::SignatureTrunctation. What's the difference? Looks like that also did symmetric hmac.
Can you help me understand why that didn't catch the issue? Should that test case be updated in any way for protection on the RSA/ECDSA cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TimHannMSFT internally RSA/ECDSA require the signature bytes to be the correct size, so any truncation will be caught by the .net runtimes.
Signature provider tests missed this because they were being told an incorrect expected size from the JsonWebTokenHandler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SymmetricSignatures are now ensuring the size of the signature matches the algorithm.
Authenticated Encryption needed special processing as only the first half of the signature is considered for Aes128CbcHmacSha256, Aes128CbcHmacSha384 and Aes128CbcHmacSha512.