You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Like this the JWT signature of the Token is not encoded correctly so I would expect an SignatureException but the lib extracts the token correctly, so what happens here with the trailing}?
The text was updated successfully, but these errors were encountered:
Your test does not actually change the signature, which in cryptographic contexts, is always a byte array. Instead, your test is changing a text encoding of the byte array. They are different things.
JJWT uses a very fast Base64(Url) decoder that ignores invalid characters in the string prefix and suffix to still result in the original signature byte array. Because again, for cryptography, it's not the text encoding we care about - it's always the byte arrays (claims byte array, signature byte array) we care about. If anything in either of these underlying byte arrays is changed, then yes, the cryptographic assertions should (and will) definitely fail.
You have to remember why signatures exist. From our documentation, signing JWTs:
guarantees it was created by someone we know (it is authentic) as well as
guarantees that no-one has manipulated or changed it after it was created (its integrity is maintained).
Just prepending or appending invalid text to try to 'trick' the algorithm doesn't change the integrity of the claims or signature byte arrays, nor the authenticity of the claims byte array, because those byte arrays are still obtained intact.
Additionally, occasionally, changing some of the characters in the middle of the string may not change the underlying byte arrays either, because of the way Base64 works. Please see #518 and its referenced issues and links for more information on why.
So, in summary, what really matters in cryptographic contexts is not if you mess around with the strings and text encoding, but if you change the underlying byte arrays, then the checks will fail.
Hey all
I work with Version:
0.10.7
I don't understand a behaviour of the lib. So I have the following:
Code to parse a token:
JWT Token ends for example with a non base64 alphabet sign
}
for example like:Like this the JWT signature of the Token is not encoded correctly so I would expect an
SignatureException
but the lib extracts the token correctly, so what happens here with the trailing}
?The text was updated successfully, but these errors were encountered: