Unable to verify signature of AWS JWTs
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- aws, javascript, node.js
- Área
- authentication, backend, security
Línea de trabajo
Comienza con la reproducción en TypeScript en jsonwebtoken.verify y compara sus entradas y opciones con la llamada de Python jwt.decode; el issue no menciona archivos ni pruebas del repositorio. Determina por qué el mismo JWT ES256 y la misma clave PEM producen resultados de verificación diferentes, documenta después una causa reproducible y confirma un comportamiento de verificación coincidente sin debilitar las comprobaciones de firma.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
I have some JWTs obtained from AWS/Cognito with the Elastic Load Balancer performing authentication for me. I also have the associated public key from the documented endpoints for the Cognito userpool. However the jsonwebtoken library says the signature is invalid (JsonWebTokenError: invalid signature), except when I use the same input (same JWT and public key in PEM format) in PyJWT Python code, this decodes/verifies without issue. There is no information to point to why jsonwebtoken is unable to verify the JWT/PEM when another library (PyJWT) can. I have tried ignoring any expiration checking in case this is the cause of the "invalid signature", such as ignoreExpiration, clockTolerance, and maxAge, without success. The only discrepancy I can see is the jsonwebtoken library must remove the base64 padding (=) from the JWT first.
Is there any known reason why jsonwebtoken would be unable to verify a signature which can be verified with another library? Perhaps some assumptions about the format/layout/syntax of the inputs which AWS/Cognito is not respecting.
Reproduction
Python code:
import jwt
import requests
import base64
import json
encoded_jwt = """eyJ0e
......
tE5Bg=="""
pub_key = """-----BEGIN PUBLIC KEY-----
MFkw
.....
J5og==
-----END PUBLIC KEY-----"""
payload = jwt.decode(encoded_jwt, pub_key, algorithms=['ES256'], leeway=10000)
print('Payload: '+ str(payload)) #This works fine
TypeScript code:
userJWT = userJWT.replace(/=/g, '');
// This fails, with JsonWebTokenError: invalid signature
return jsonwebtoken.verify(userJWT, this.pem,
{algorithms: ['ES256'], ignoreExpiration: true, clockTolerance: 100000, maxAge: "1 day"});
Environment
Please provide the following:
- Version of this library used:
- jsonwebtokens=8.5.1
- PyJWT = 1.7.1
- Version of the platform or framework used, if applicable:
- Python 3.8.10
- Node v17.4.0
- Other relevant versions (language, server software, OS, browser):
- Ubuntu 21.04 (Kernel 5.14)
- Other modules/plugins/libraries that might be involved:
- Lenguaje dominante
- JavaScript
- Estrellas
- 18.2k
- Forks
- 1.3k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de auth0/node-jsonwebtoken
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
auth0/node-jsonwebtoken#1042 · 1 comentario ·
-
`jwt.sign()` callback is executed twice for "The payload already has an "..." property" errors Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
auth0/node-jsonwebtoken#1000 · 2 comentarios · 1 reacción ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 65/100
auth0/node-jsonwebtoken#1046 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
auth0/node-jsonwebtoken#1034 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
auth0/node-jsonwebtoken#1032 ·
Todos los issues de auth0/node-jsonwebtoken
Issues similares
-
Update HugeIcons library Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
antfu-collective/icones#398 ·
-
ECmail.com Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
wesbos/burner-email-providers#554 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
components-web-app/docs#92 ·