JWT::EncodedToken calls key_finder before checking the token's algorithm
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #784 de @anakinj — fusionado
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- Medio día
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- ruby, security
- Área
- authentication, security
Línea de trabajo
The bug sits in lib/jwt/encoded_token.rb: in valid_signature?, key_finder.call(self) runs before the verifiers are built from the allowed algorithms. Reproduce with the snippet in the issue, which should show the finder called once before JWT::VerificationError. Done means a disallowed alg raises JWT::IncorrectAlgorithm without calling the finder, while JWK-supplied algorithm calls still pass the existing specs.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
JWT.decode rejects a token with a disallowed alg before looking up a key. JWT::EncodedToken#verify_signature! calls key_finder first, so tokens that could never pass still trigger the lookup.
Signature verification still fails correctly, so this isn't a bypass. The concern is that key finders often fetch a remote JWKS, which lets an unauthenticated alg: none or HS256 token cause outbound requests when the application expects only RS256.
rsa = OpenSSL::PKey::RSA.generate(2048)
token = JWT.encode({ 'sub' => 'x' }, 'secret', 'HS256')
calls = 0
finder = lambda { |_token|
calls += 1
rsa.public_key
}
JWT::EncodedToken.new(token).verify_signature!(algorithm: 'RS256', key_finder: finder)
# => JWT::VerificationError: Signature verification failed (calls == 1)
JWT.decode(token, nil, true, algorithm: 'RS256') { |_header| rsa.public_key }
# => JWT::IncorrectAlgorithm: Expected a different algorithm (block not called)
Reproduced on 3.3.1, and an alg: none token behaves the same way. lib/jwt/encoded_token.rb is unchanged on main.
Cause: EncodedToken#valid_signature? evaluates key_finder.call(self) before creating the verifiers from the allowed algorithms.
Suggestion: When algorithm: is given, check the token's alg against it before calling key_finder, and raise JWT::IncorrectAlgorithm if it isn't allowed. Calls that rely on a JWK to supply the algorithm would need to keep working.
Posted by Claude on behalf of @anakinj.
- Lenguaje dominante
- Ruby
- Estrellas
- 3.7k
- Forks
- 381
- Merge medio
- 17 h 10 min
- PR fusionados (30 d)
- 11
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 jwt/ruby-jwt
-
Release with release-pleaseAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 15/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
jwt/ruby-jwt#743 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
jwt/ruby-jwt#723 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
feature
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
jwt/ruby-jwt#428 · 7 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Introduce JWE supportAbiertoenhancement feature help wanted up for grabs
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
jwt/ruby-jwt#80 · 11 comentarios · 8 reacciones ·
Los mantenedores suelen responder en 1 día
Todos los issues de jwt/ruby-jwt
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
riverqueue/river#1576 ·
Los mantenedores suelen responder en 1 día
-
respond_to? on a poly receiver answers true for a program class's private or protected methodAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
Issue in config.yaml fileAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
TheOdinProject/curriculum#31512 ·
Los mantenedores suelen responder en 1 día
-
area/web interface
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día