question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to verify token with alg: 'none'

See original GitHub issue

Attempting to verify a token with the alg header set to ‘none’ always fails. This is because the implementation of the NoneAlgorithm ‘verify’ unconditionally returns False.

    def verify(self, msg, key, sig):
        return False

Expected Result

Verifying any token with the alg header set to ‘none’ should always succeed whenever the token has a valid format.

Actual Result

Verifying the token fails.

Traceback (most recent call last):
  File "C:/Users/chili/PycharmProjects/untitled/jwtmaker.py", line 7, in <module>
    decoded = jwt.decode(encoded, None, algorithms=['none'])
  File "C:\Users\chili\PycharmProjects\untitled\venv\lib\site-packages\jwt\api_jwt.py", line 92, in decode
    jwt, key=key, algorithms=algorithms, options=options, **kwargs
  File "C:\Users\chili\PycharmProjects\untitled\venv\lib\site-packages\jwt\api_jws.py", line 156, in decode
    key, algorithms)
  File "C:\Users\chili\PycharmProjects\untitled\venv\lib\site-packages\jwt\api_jws.py", line 223, in _verify_signature
    raise InvalidSignatureError('Signature verification failed')
jwt.exceptions.InvalidSignatureError: Signature verification failed

Reproduction Steps

import jwt
encoded = jwt.encode({'some': 'payload'}, None, algorithm='none')
decoded = jwt.decode(encoded, None, algorithms=['none'])

System Information

$ python -m jwt.help
{
  "cryptography": {
    "version": "2.6.1"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.6.5"
  },
  "platform": {
    "release": "10",
    "system": "Windows"
  },
  "pyjwt": {
    "version": "1.7.1"
  }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

2reactions
kevjincommented, Mar 1, 2019

verifying token with ‘none’ is a security vulnerability https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/

0reactions
github-actions[bot]commented, Aug 15, 2022

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hacking JWT : Exploiting the “none” algorithm | by sourav kumar
The tokens are signed by server's key, so the server is able to verify if the token is legitimate or not. JWT is...
Read more >
Verifying Auth0 JWT throws invalid algorigthm - Stack Overflow
What I am trying to do now is to verify the token using jsonwebtoken. The token is signed with an RS256 algorithm. I...
Read more >
Critical vulnerabilities in JSON Web Token libraries - Auth0
Well, let's try to verify a token. First, we need to determine what algorithm was used to generate the signature. No problem, there's...
Read more >
JWT Errors | Documentation - Web3Auth
"Error occurred while verifying params unable to verify jwt token" error could be because of the following reasons: ... The JWKS endpoint is...
Read more >
Troubleshooting JWT validation - Google Cloud
Check that the "iss" (issuer) claim in your JWT token matches the first parameter of the endpoints.Issuer object. Error: Audience not allowed. If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found