4.4medium
File reference keys leads to incorrect hashes on HMAC algorithms
- Severity
- 4.4medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.21% (higher than 11% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-7322-jrq4-x5hf
Description
JWT is a library to work with JSON Web Token and JSON Web Signature. Prior to versions 3.4.6, 4.0.4, and 4.1.5, users of HMAC-based algorithms (HS256, HS384, and HS512) combined with `Lcobucci\JWT\Signer\Key\LocalFileReference` as key are having their tokens issued/validated using the file path as hashing key - instead of the contents. The HMAC hashing functions take any string as input and, since users can issue and validate tokens, users are lead to believe that everything works properly. Versions 3.4.6, 4.0.4, and 4.1.5 have been patched to always load the file contents, deprecated the `Lcobucci\JWT\Signer\Key\LocalFileReference`, and suggest `Lcobucci\JWT\Signer\Key\InMemory` as the alternative. As a workaround, use `Lcobucci\JWT\Signer\Key\InMemory` instead of `Lcobucci\JWT\Signer\Key\LocalFileReference` to create the instances of one's keys.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| lcobucci jwt | >= 3.4.0, < 3.4.6, >= 4.0.0, < 4.0.4, >= 4.1.0, < 4.1.5, from 3.4.0 before 3.4.6, from 4.0.0 before 4.0.4, from 4.1.0 before 4.1.5 | CVE List, NVD |
| lcobucci/jwt (Packagist) | from 3.4.0 before 3.4.6, from 4.0.0 before 4.0.4, from 4.1.0 before 4.1.5 | GitHub Advisory Database |
All scores
| GitHub_M | 4.4medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N |
| GitHub | 4.4medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N |
| NVD | 3.3low CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N |
| NVD | 2.1low CVSS:2.0 | AV:L/AC:L/Au:N/C:N/I:P/A:N |
Classification
What each source says
CVE List
JWT is a library to work with JSON Web Token and JSON Web Signature. Prior to versions 3.4.6, 4.0.4, and 4.1.5, users of HMAC-based algorithms (HS256, HS384, and HS512) combined with `Lcobucci\JWT\Signer\Key\LocalFileReference` as key are having their tokens issued/validated using the file path as hashing key - instead of the contents. The HMAC hashing functions take any string as input and, since users can issue and validate tokens, users are lead to believe that everything works properly. Versions 3.4.6, 4.0.4, and 4.1.5 have been patched to always load the file contents, deprecated the `Lcobucci\JWT\Signer\Key\LocalFileReference`, and suggest `Lcobucci\JWT\Signer\Key\InMemory` as the alternative. As a workaround, use `Lcobucci\JWT\Signer\Key\InMemory` instead of `Lcobucci\JWT\Signer\Key\LocalFileReference` to create the instances of one's keys.
GitHub Advisory Database
Impact
Users of HMAC-based algorithms (HS256, HS384, and HS512) combined with Lcobucci\JWT\Signer\Key\LocalFileReference as key are having their tokens issued/validated using the file path as hashing key - instead of the contents.
The HMAC hashing functions take any string as input and, since users can issue and validate tokens, people are lead to believe that everything works properly.
Patches
All versions have been patched to always load the file contents, deprecated the Lcobucci\JWT\Signer\Key\LocalFileReference, and suggest Lcobucci\JWT\Signer\Key\InMemory as the alternative.
Workarounds
Use Lcobucci\JWT\Signer\Key\InMemory instead of Lcobucci\JWT\Signer\Key\LocalFileReference to create the instances of your keys:
-use Lcobucci\JWT\Signer\Key\LocalFileReference;
+use Lcobucci\JWT\Signer\Key\InMemory;
-$key = LocalFileReference::file(__DIR__ . '/public-key.pem');
+$key = InMemory::file(__DIR__ . '/public-key.pem');
NVD (es)
JWT es una biblioteca para trabajar con JSON Web Token y JSON Web Signature. Antes de las versiones 3.4.6, 4.0.4 y 4.1.5, los usuarios de los algoritmos basados en HMAC (HS256, HS384 y HS512) combinados con "Lcobucci\JWT\Signer\Key\LocalFileReference" como clave están emitiendo/validando sus tokens usando la ruta del archivo como clave de hashing - en lugar del contenido. Las funciones de hashing HMAC aceptan cualquier cadena como entrada y, dado que los usuarios pueden emitir y comprobar tokens, los usuarios son llevados a creer que todo funciona correctamente. Las versiones 3.4.6, 4.0.4 y 4.1.5 han sido parcheadas para cargar siempre el contenido del archivo, desaprobando la función "Lcobucci\JWT\Signer\Key\LocalFileReference", y sugiriendo "Lcobucci\JWT\Signer\Key\InMemory" como alternativa. Como solución, use "Lcobucci\JWT\SignerKey\InMemory" en lugar de "Lcobucci\JWT\SignerKey\LocalFileReference" para crear las instancias de las claves propias
References
| https://github.com/lcobucci/jwt/security/advisories/GHSA-7322-jrq4-x5hf | patch, third-party-advisory, web | |
| https://github.com/lcobucci/jwt/commit/8175de5b841fbe3fd97d2d49b3fc15c4ecb39a73 | patch, third-party-advisory, web | |
| https://github.com/lcobucci/jwt/commit/c45bb8b961a8e742d8f6b88ef5ff1bd5cca5d01c | patch, third-party-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2021-41106 | advisory | |
| https://github.com/FriendsOfPHP/security-advisories/blob/master/lcobucci/jwt/CVE-2021-41106.yaml | web | |
| https://github.com/lcobucci/jwt | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-41106 changed 2024-08-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-7322-jrq4-x5hf changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2021-41106 changed 2026-06-17 | Public domain |