jwt.verify accepts tokens with unrecognized `crit` header extensions (RFC 7515 §4.1.11)
@ArockiaRajamanickam ya está trabajando en esto.
Desde el 2/8/2026.
- #1041 de @ArockiaRajamanickam — abierto
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- javascript, node.js
- Área
- authentication, security
Línea de trabajo
Comienza en verify.js en la ruta de decoded-header; ejecuta la reproducción de RSA proporcionada y compara su comportamiento con RFC 7515 §4.1.11 y la referencia validate_crit.ts de jose. Se considera terminado cuando los encabezados crit no compatibles o malformados se rechazan durante la verificación y cualquier comportamiento de opt-in del llamador queda cubierto por pruebas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
[email protected] accepts JWTs whose JOSE header contains a crit array listing extension Header Parameters that the library does not understand or process. Per RFC 7515 §4.1.11, such tokens must be rejected:
If any of the listed extension Header Parameters are not understood and supported by the recipient, then the JWS MUST be rejected.
A grep of the installed [email protected] source shows no crit handling at all — the field is silently ignored during verification. As a result, a signer who relies on crit to mandate that verifiers respect an extension (e.g. a key-binding or policy header) gets no enforcement when the verifier is jsonwebtoken, even though the signer marked the extension as critical.
Reproduction
// npm i [email protected]
const jwt = require('jsonwebtoken');
const crypto = require('crypto');
const { publicKey, privateKey } = crypto.generateKeyPairSync('rsa', { modulusLength: 2048 });
const pubPem = publicKey.export ({ type: 'spki', format: 'pem' });
const privPem = privateKey.export({ type: 'pkcs8', format: 'pem' });
// Sign a token that declares an extension param as critical
const token = jwt.sign(
{ sub: 'x', role: 'admin' },
privPem,
{ algorithm: 'RS256',
header: { crit: ['x-attack-vector'], 'x-attack-vector': true } });
// Verify — RFC 7515 §4.1.11 requires rejection because jsonwebtoken does not
// understand or process the 'x-attack-vector' extension.
console.log(jwt.verify(token, pubPem, { algorithms: ['RS256'] }));
Observed output:
{ sub: 'x', role: 'admin', iat: 1779849601 }
Expected: a verification error (e.g. JsonWebTokenError: critical header parameter 'x-attack-vector' is not understood).
Cross-library comparison
[email protected] rejects the same token, citing the same RFC clause:
ERR_JOSE_NOT_SUPPORTED: Extension Header Parameter "x-attack-vector" is not recognized
So a deployment that issues tokens with crit-protected extensions via one library and verifies them with jsonwebtoken loses the protection the signer intended.
Why it matters
crit is the mechanism JWS provides for a signer to require that a particular extension header be honored. Concrete examples in the wild:
b64(RFC 7797) — signer asserts the payload is not base64url-encoded; a verifier ignoringcritwill treat it as encoded and either fail or, worse, validate a different payload than the one signed.- Custom security-policy extensions (e.g. token-binding hints, audience-restriction extensions, replay-protection nonces) where the signer explicitly demands enforcement.
A verifier that silently strips crit defeats the whole purpose of the field as defined in RFC 7515.
Suggested fix direction
In verify.js, after the header is decoded:
- If
header.critexists, it must be a non-empty array of strings (per §4.1.11). - Reject if
critlists any name that this library does not implement. Sincejsonwebtokendoes not implement anycritextensions, the simplest correct behavior is to reject any token whosecritis non-empty unless the caller opts in via an option likecrit: ['name1', ...]enumerating extensions the caller has handled out-of-band.
jose's implementation is a small reference.
Environment
jsonwebtoken9.0.3 (current latest on npm)- Node v26.0.0
- macOS 14
- Lenguaje dominante
- JavaScript
- Estrellas
- 18.2k
- Forks
- 1.3k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la 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" errorsPosiblemente ocupada @cobyfrombrooklyn-bot la tomó hace 227 días. 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 45/100
auth0/node-jsonwebtoken#1048 ·
-
verify() resolves a string secret by attempting createPublicKey() first, costing 4x-52x on the HS* pathPosiblemente ocupada @Hashim1999164 la tomó hace 22 días. Abierto
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 ·
Todos los issues de auth0/node-jsonwebtoken
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
yjh051108/dsh-routing-suite#216 ·
-
bug user-priority/P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
t8y2/dbx#11718 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 4 días
-
bug confirmed perf
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
videojs/video.js#9400 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
agent/scanner bug hive/hosted-available-lke648397-260827-5n31
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día