Skip to content
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

Support base64 padding in json web tokens #98

Open
wcauchois opened this issue Dec 22, 2020 · 2 comments
Open

Support base64 padding in json web tokens #98

wcauchois opened this issue Dec 22, 2020 · 2 comments

Comments

@wcauchois
Copy link

This library appears to have taken a hard-line stance that = characters should not be allowed in the JWT encoding, per issue #49 and upstream at auth0/node-jsonwebtoken#607 - and it seems this is in keeping with the JWT spec.

However, I'm working with a feature in AWS whereby you can have a load balancer authenticate users using Cognito and then pass JWTs in special headers to your service. I am trying to verify those JWTs. The tokens include = characters (this is even documented here - "The JWT format includes a header, payload, and signature that are base64 URL encoded and includes padding characters at the end"). Although I realize these tokens are invalid, I'm not in a position to change their format.

One would think a workaround would be to just strip these padding characters from the token, but if the token payload includes padding characters then removing these invalidates the signature.

Fundamentally, I think that in order to verify these tokens while still using the jsonwebtoken library, then this library would need to be changed. I think specifically this line in verify-stream.js.

Would the maintainers of this library consider supporting padding characters in this regex? I'm not sure whether there would be negative security implications of universally supporting padding characters. If there are, perhaps this could be enabled behind a flag.

Thanks!

@dimisus
Copy link

dimisus commented May 7, 2021

Fun fact: I use the jsonwebtoken npm library to both sign and verify tokens in my backend. I came across an issue where I generate a jwt token which in the end has multiple '=' using jwt.sign(...), but I cannot verify the very same token with jwt.verify(...) without "manually" removing the paddings/equal signs.

@panva
Copy link

panva commented May 7, 2021

@dimisus jsonwebtoken does not produce JWTs with base64 encoding, neither the special characters, nor padding. If that's the case for you then please open an issue in jsonwebtoken with reproduction steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants