DEV Community

Discussion on: How to invalidate a JWT using a blacklist

Collapse
 
hessman_ profile image
Anthony Domingue • Edited

The token is in the header "Authorization" right ? Any user can update the Authorization token in the request. Maybe it's not easy for everyone but it is possible.
JWT is encoded in base64, but in base64 you can add padding with "=" without changing the encoded message. "Hi dev.to !" in base64 is "SGkgZGV2LnRvICE=" but also "SGkgZGV2LnRvICE==" or "SGkgZGV2LnRvICE===".
So if you check the encoded token in the denylist you can just add "=" at the end of the token to bypass the denylist and use the token without changing the decoded value.
Here is the RFC for the base64: tools.ietf.org/html/rfc4648

Thread Thread
 
chukwutosin_ profile image
Tosin Moronfolu

Oh wow, didn't realize this. Thank you for sharing. Will check it out.

Thread Thread
 
phlash profile image
Phil Ashby

This is why our design revoked tokens via their jti field, which is not changeable provided the tokens are correctly signed (with an RSA or elliptic curve key pair). it does require all tokens to be parsed, but we can delegate that to a trusted library that should be resistant to attack...