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

Medium 4.4 Published Updated

Users relying on file path references for HMAC keys in this JWT library may inadvertently use the path string as the secret, allowing token forgery.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Local or same network only
Victim action needed
Not needed
Fix
Available

What is CVE-2021-41106?

CVE-2021-41106 is a medium-severity vulnerability in lcobucci jwt, published on 28 Sep 2021. It can only be exploited from the same machine or local network, with no action from the victim.

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

Weakness: CWE-345

Which versions are affected by CVE-2021-41106?

6 open source packages ship an affected version, including lcobucci/jwt. It affects 1 product.

PackageAffectedFixed in
lcobucci/jwt PackagistFrom 3.4.03.4.6
lcobucci/jwt PackagistFrom 3.4.03.4.6
lcobucci/jwt PackagistFrom 4.0.04.0.4
lcobucci/jwt PackagistFrom 4.0.04.0.4
lcobucci/jwt PackagistFrom 4.1.04.1.5
lcobucci/jwt PackagistFrom 4.1.04.1.5

Products include Lcobucci Jwt.

How do I fix CVE-2021-41106?

Upgrade lcobucci/jwt to a fixed version for your release line: 3.4.6, 4.0.4 or 4.1.5.

Is CVE-2021-41106 being exploited?

There is no known exploitation of CVE-2021-41106 in the wild and no public exploit code.

Sources

Also known as GHSA-7322-jrq4-x5hf.

Is CVE-2021-41106 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free