Skip to content

Why does our JWT token still validate even after changing the last digit? #6397

Answered by yashtandon113
amarantmeida asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @amarantmeida
Thanks for asking the question.

For example, this is the generated JWT token.

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdHJlYW1JZCI6Imhsc2RlbW8iLCJ0eXBlIjoicHVibGlzaCIsImV4cCI6OTk5OTk5OTk5OX0.gvckkkh5zPp8ZWfMHue8xm6_dwCAhvqVnrq7Nua46d4

Now if we change the last digit to 5, 6, or 7, it still validates. But if I make it to 3 or 8, then it becomes invalid.

This is an expected behaviour of JWT’s token generation algorithm. Check out the article below for more details.

https://medium.com/@mark_huber/decoding-the-jwt-anomaly-when-changing-a-tokens-last-character-doesn-t-break-verification-d6ab68627afb

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lastpeony
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants