-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Rename decode
function unsafeDecode
to highlight the risk
#952
Comments
…ht the risk auth0#952 I have made the changes as per above mentioned in the above comment.
Very interesting proposal. I would just suggest calling it |
I would suggest const unverifiedToken = unverifiedDecode(rawToken);
const verifiedToken = verifyDecoded(unverifiedToken); The current
|
Hi @jonaskello, I think Also, verifying a token after it has been decoded is impossible. @aalu-love, thanks for the PR. Would you update it to use camelCase as @youssef-jbili suggested? Otherwise, I can do it at the end of the week 😁 |
@marine-mb When you decode you get all three parts as can be seen here return {
header: decoded.header,
payload: payload,
signature: decoded.signature
}; So not only the payload. However I think you might be saying the signareture is calculated on the raw base64 string? In that case I understand the limitation. |
Hi @jonaskello, Thank you for your answer. And even if we could give the decoded token, I think it is dangerous to give the impression it is correct to exploit data in the JWT before verifying the signature. |
decode
function unsafe_decode
to highlight the riskdecode
function unsafeDecode
to highlight the risk
#972 would allow sanitising/validating the token payload without using For example if a backend is expecting a certain field of the payload to be a certain value e.g. |
Describe the problem you'd like to have solved
I'm a DevSec. I help developers teams find and fix their vulnerabilities.
In two of my last missions, I've seen developers using
decode
instead ofverify
even if the documentation has been improved.Describe the ideal solution
To avoid this and reduce the vulnerable apps, I think it would be great to rename the
decode
function and call itunsafeDecode
. (as suggested by @youssef-jbili)Other libraries have done it and it helps developers reduce their mistakes:
dangerouslySetInnerHTML
for ReactbypassSecurityTrustHtml
for AngularI can make a Pull Request if you think it is a good idea.
The text was updated successfully, but these errors were encountered: