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

Regex doesn't recognize JWT token #70

Open
vdb-sander opened this issue Jun 2, 2022 · 2 comments
Open

Regex doesn't recognize JWT token #70

vdb-sander opened this issue Jun 2, 2022 · 2 comments

Comments

@vdb-sander
Copy link

In the latest version (2.2.5) the regex to find the JWT token is set to the following. However, the payload of the token I was about to test started with eyI. This didn't match the regex and resulted in Cannot find a valid JWT.

eyJ[A-Za-z0-9_\/+-]*\.eyJ[A-Za-z0-9_\/+-]*\.[A-Za-z0-9._\/+-]*

Modifying all regexes in the code to the following resolved my issue.

eyJ[A-Za-z0-9_\/+-]*\.ey[A-Za-z0-9_\/+-]*\.[A-Za-z0-9._\/+-]*
@ticarpi
Copy link
Owner

ticarpi commented Jun 18, 2022

Nice one.
Yes, this is a very narrow case, but it can happen.
The regex /eyJ./ matches the first block (4 chars) of base64 output for any string beginning with /{"[a-zA-Z]/ - that is, any JSON object with a key/name starting with an alpha char.
If the JSON object has a first key/name as a quoted numeric value (e.g. {"1":"one","2":"two"}), then the base64 value will match regex /eyI./
I have never seen this myself, but changing the regex of the JSON base64 sections to the following would be wise to cover those edge cases (while minimisng false positives):
/ey[IJ][A-Za-z0-9_\/+-]*/
So:
/ey[IJ][A-Za-z0-9_\/+-]*\.ey[IJ][A-Za-z0-9_\/+-]*\.[A-Za-z0-9._\/+-]*/

@fdaugan
Copy link

fdaugan commented Feb 3, 2024

It happens to JWT of my client too with start eyA

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

No branches or pull requests

3 participants