High, CVSS 8.1PackagistPublished
PHP JWT Framework: JWSVerifier uses algorithm from unprotected header, enabling algorithm confusion attacks
GHSA-jc38-x7x8-2xc8
- Affected
- Packagist web-token/jwt-bundle < 3.4.10; >= 4.0.0, < 4.0.7; >= 4.1.0, < 4.1.7
- Fixed in
- 4.0.73.4.104.1.7· Vendor fix available
- Issue
- JWSVerifier::getAlgorithm() in src/Library/Signature/JWSVerifier.php (line 144) merges protected and unprotected headers using PHP's spread operator: In PHP, when spreading arrays with duplicate string keys, the last array's values take precedence. Since the unprotected header (getHeader()) is spread second, an attacker can override the integrity-protected alg parameter by placing a different value in the unprotected header. This creates a Time-of-Check/Time-of-Use (TOCTOU) vulnerability: 1. HeaderCheckerManager validates alg from the protected header 2. JWSVerifier uses alg from the unprotected header for actual verification The same issue exists in JWEDecrypter.php (lines 120-124) where arraymerge() exhibits the same last-wins behavior for alg and enc. Affected Code JWSVerifier.php line 144 — Spread operator merge order allows unprotected header to override alg: JWEDecrypter.php lines 120-124 — arraymerge() with same last-wins behavior: Attack Vectors Vector A — Mixed key…
Recommended action: Upgrade to 4.1.7, 4.0.7 or 3.4.10 by release line, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.