-
Notifications
You must be signed in to change notification settings - Fork 39
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
Token avalid for another api audience gives misleading error message #19
Comments
The problem is not related to wrong audience, but more like wrong tenant. For sure it's possible to display an explicit message when |
Though I think it's unlikely kid is sensitive in itself, and a smart attacker could anyway figure out if the kid is wrong or not with a timing attack leveraging the different execution times of the branches. |
I know way too little about JWT and their security. But I doubt that this infos (that the token is not valid for the audience/domain) is a security concern. An attacker could also just run the code locally and figure that out. In fact he could just call https://{domain}/.well-known/jwks.json and extract the correct kid. That key id is not a very secret info. |
Published in 0.3.0. |
If you create an access token for a different API audience, or different tenant, then obviously the authorization should fail.
However the error message is 401
"Malformed token"
.This is quite misleading, normally when a token is malformed, it is because you just gave a random string, or because you forgot to copy-paste a few characters.
The error comes from:
fastapi-auth0/src/fastapi_auth0/auth.py
Lines 118 to 140 in ae5256d
The
kid
is different (because of different api audience), and therefore thersa_key
is empty, and a generalJWTError
is raised.Is it possible to give a better error message. Maybe something like
"Token not authorized"
or"Token has wrong audience"
would be better suited.The text was updated successfully, but these errors were encountered: