GHSA-7322-jrq4-x5hf

Suggest an improvement
Source
https://github.com/advisories/GHSA-7322-jrq4-x5hf
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2021/09/GHSA-7322-jrq4-x5hf/GHSA-7322-jrq4-x5hf.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-7322-jrq4-x5hf
Aliases
Published
2021-09-29T17:09:40Z
Modified
2024-02-16T08:15:03.944377Z
Severity
  • 4.4 (Medium) CVSS_V3 - CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N CVSS Calculator
Summary
File reference keys leads to incorrect hashes on HMAC algorithms
Details

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');
Database specific
{
    "nvd_published_at": "2021-09-28T21:15:00Z",
    "cwe_ids": [
        "CWE-345"
    ],
    "severity": "MODERATE",
    "github_reviewed": true,
    "github_reviewed_at": "2021-09-28T21:27:18Z"
}
References

Affected packages

Packagist / lcobucci/jwt

Package

Name
lcobucci/jwt
Purl
pkg:composer/lcobucci/jwt

Affected ranges

Type
ECOSYSTEM
Events
Introduced
3.4.0
Fixed
3.4.6

Affected versions

3.*

3.4.0
3.4.1
3.4.2
3.4.3
3.4.4
3.4.5

Packagist / lcobucci/jwt

Package

Name
lcobucci/jwt
Purl
pkg:composer/lcobucci/jwt

Affected ranges

Type
ECOSYSTEM
Events
Introduced
4.0.0
Fixed
4.0.4

Affected versions

4.*

4.0.0
4.0.1
4.0.2
4.0.3

Packagist / lcobucci/jwt

Package

Name
lcobucci/jwt
Purl
pkg:composer/lcobucci/jwt

Affected ranges

Type
ECOSYSTEM
Events
Introduced
4.1.0
Fixed
4.1.5

Affected versions

4.*

4.1.0
4.1.1
4.1.2
4.1.3
4.1.4