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

Possibility to override the alg header when encoding tokens #557

Open
anakinj opened this issue Mar 25, 2023 · 2 comments
Open

Possibility to override the alg header when encoding tokens #557

anakinj opened this issue Mar 25, 2023 · 2 comments
Milestone

Comments

@anakinj
Copy link
Member

anakinj commented Mar 25, 2023

Currently it's not possible to override the alg header value using the header parameter. To me it seems intuitive not to touch the user specified values and just go with them.

Suggestion is to not to populate the alg header if that is already given by the user.

@anakinj anakinj added this to the Version 3.x milestone Mar 25, 2023
@codespearhead
Copy link

codespearhead commented Jan 15, 2024

From what I understand this would be a massive security issue.

"The widest known issue is probably that the header allows for a[n] alg claim to specify which algorithm was used to sign the token. Bad implementations would (by default) use this claim to choose how to verify the token; which means an attacker could simply put "alg":"none" , claim to be the most super of admins, and the application would accept those claims and grant all the access." [Source]

@anakinj anakinj changed the title Possibility to override the alg header Possibility to override the alg header when encoding tokens Jan 15, 2024
@anakinj
Copy link
Member Author

anakinj commented Jan 15, 2024

That would for sure be a big problem. Changed the subject to hopefully be a bit clearer what the scope is.

The intention here is to preserve the user defined alg value passed to the encoding logic. Currently the alg value is always taken from the used algorithm, but the user provided value could as well just be used.

For example:

JWT.encode(payload, key, 'HS256', header_fields={alg: 'CustomALG'})

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

2 participants