GHSA-jc38-x7x8-2xc8: PHP JWT Framework: JWSVerifier uses algorithm from unprotected header, enabling algorithm confusion attacks
Noroxi assessment
Priority: Monitor (action score 0/100)
- The sources we track (CISA KEV, Exploit-DB, Metasploit, Nuclei, GitHub) show no public exploit code or exploitation in the wild.
- Anyone who can reach it over the internet can trigger it. No account or password is required. No user action is required. Special conditions such as timing or configuration are required.
- Fixed version: web-token/jwt-bundle (Packagist) 4.0.7, 4.1.7, 3.4.10; web-token/jwt-experimental (Packagist) 4.0.7, 4.1.7, 3.4.10; web-token/jwt-framework (Packagist) 4.0.7, 4.1.7, 3.4.10.
Low priority for now. Upgrade to web-token/jwt-bundle (Packagist) 4.0.7, 4.1.7, 3.4.10; web-token/jwt-experimental (Packagist) 4.0.7, 4.1.7, 3.4.10; web-token/jwt-framework (Packagist) 4.0.7, 4.1.7, 3.4.10 or later.
Generated automatically from the record's data: CVSS (NVD and CNA), CISA KEV and SSVC, FIRST EPSS, exploit sources, fixed versions. How we calculate it
Primary sources: OSV
## Summary `JWSVerifier::getAlgorithm()` in `src/Library/Signature/JWSVerifier.php` (line 144) merges protected and unprotected headers using PHP's spread operator: ```php $completeHeader = [...$signature->getProtectedHeader(), ...$signature->getHeader()]; ``` 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 `array_merge()` 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`: ```php $completeHeader = [...$signature->getProtectedHeader(), ...$signature->getHeader()]; ``` **JWEDecrypter.php lines 120-124** — `array_merge()` with same last-wins behavior: ```php $completeHeader = array_merge( $jwe->getSharedProtectedHeader(), $jwe->getSharedHeader(), $recipient->getHeader() ); ``` ## Attack Vectors ### Vector A — Mixed key sets (HIGH probability) If the application uses a JWKSet containing keys of different types (common in multi-tenant or federation scenarios), the JWSVerifier iterates all keys (line 86). An attacker can force a different algorithm that matches a different key in the set. ### Vector B — alg ONLY in unprotected header (HIGH probability) If `alg` is placed EXCLUSIVELY in the unprotected header (not in the protected header at all), `HeaderCheckerManager::checkDuplicatedHeaderParameters()` does NOT trigger. The JSON Flattened/General serializers allow tokens with no protected header or a protected header without `alg`. RFC 7515 Section 4.1.1 states `alg` MUST be integrity-protected, but the library does not enforce this. ### Vector C — Direct JWSVerifier usage (HIGH probability) `JWSLoader` takes `?HeaderCheckerManager` (nullable). If developers use `JWSVerifier` directly or create `JWSLoader` without a `HeaderCheckerManager`, the duplicate header check never runs. ## Contrast with JWSBuilder (safe) `JWSBuilder::findSignatureAlgorithm()` (line 196) uses `[...$header, ...$protectedHeader]` where protected wins. It also has `checkDuplicatedHeaderParameters()` (line 218). The JWSVerifier has **neither** safeguard. ## Proof of Concept ```php <?php // Demonstrate algorithm override via unprotected header $protected = ["alg" => "RS256", "typ" => "JWT"]; $unprotected = ["alg" => "HS256"]; $merged = [...$protected, ...$unprotected]; // $merged["alg"] === "HS256" — unprotected wins! // JSON Flattened JWS with algorithm override: $maliciousJws = json_encode([ 'payload' => base64url_encode($payload), 'protected' => base64url_encode('{"alg":"RS256"}'), 'header' => ['alg' => 'HS256'], // OVERRIDE 'signature' => base64url_encode($sig), ]); // HeaderCheckerManager validates RS256 from protected header -> PASS // JWSVerifier uses HS256 from unprotected header -> attacker's algorithm choice ``` A full working PoC demonstrating HS512-to-HS256 downgrade with mixed keysets is available upon request. ## Suggested Fix In `JWSVerifier::getAlgorithm()`, read `alg` exclusively from the protected header: ```php private function getAlgorithm(Signature $signature): Algorithm { $protectedHeader = $signature->getProtectedHeader(); if (! isset($protectedHeader['alg'])) { throw new InvalidArgumentException('The "alg" parameter must be in the protected header.'); } return $this->signatureAlgorithmManager->get($protectedHeader['alg']); } ``` For `JWEDecrypter`, reverse the merge order so protected header wins, or extract `alg`/`enc` exclusively from the protected header. ## Résolution Un correctif a été préparé sur une branche dédiée basée sur `3.4.x`, avec des tests anti-régression dédiés (fork privé temporaire de cette advisory, PR #1). **JWS algorithm confusion** — `JWSVerifier` lit le paramètre `alg` exclusivement dans le header protégé en intégrité (RFC 7515 §4.1.1) ; un `alg` placé dans le header non protégé ne peut plus surcharger l'algorithme signé. **Validation :** `php -l` OK, PHPUnit vert, aucune nouvelle erreur PHPStan introduite (différentiel nul vs `3.4.x`), aucun commentaire ajouté dans le code source. Après merge, cascade prévue `3.4.x → 4.0.x → 4.1.x`.
- Published
- Jun 18, 2026
- Updated
- Sep 10, 2026
- EPSS
- —
- CWE
- CWE-345
Report tools
Action score
0
Low priority for now.
- CVSS
- 0 / 40 · —
- CISA KEV
- 0 / 30 · Not listed
- EPSS
- 0 / 30 · —
Get told when this record changes
- Not in KEV: no record of exploitation in the wild
- No public exploit code on record
- A fix has been released
If any of these changes, we'll tell you in the daily email digest.
Is your version affected? Check itNoroxi analysis
What does it mean in your environment?
The assessment above is generated automatically from the record's data; it doesn't know your environment. Our team verifies on your systems whether this vulnerability is actually exploitable and which mitigation is enough.
We use this product, ask for helpAffected systems
Is your version affected?
Pick the product and type the version you run. It's compared with this record's version ranges in your browser; the version isn't sent anywhere.
| Vendor | Product | CPE |
|---|---|---|
| Packagist | web-token/jwt-library | pkg:composer/web-token/jwt-library |
| Packagist | web-token/jwt-bundle | pkg:composer/web-token/jwt-bundle |
| Packagist | web-token/jwt-experimental | pkg:composer/web-token/jwt-experimental |
| Packagist | web-token/jwt-framework | pkg:composer/web-token/jwt-framework |
Package-level exposure
OSV and GitHub Advisory data: ecosystem, package and range. SBOM matching uses this table.
| Ecosystem | Package | Affected range | Fix |
|---|---|---|---|
| Packagist | web-token/jwt-bundle | from 4.0.0 · before 4.0.7 | 4.0.7 |
| Packagist | web-token/jwt-bundle | from 4.1.0 · before 4.1.7 | 4.1.7 |
| Packagist | web-token/jwt-bundle | before 3.4.10 | 3.4.10 |
| Packagist | web-token/jwt-experimental | from 4.0.0 · before 4.0.7 | 4.0.7 |
| Packagist | web-token/jwt-experimental | from 4.1.0 · before 4.1.7 | 4.1.7 |
| Packagist | web-token/jwt-experimental | before 3.4.10 | 3.4.10 |
| Packagist | web-token/jwt-framework | from 4.0.0 · before 4.0.7 | 4.0.7 |
| Packagist | web-token/jwt-framework | from 4.1.0 · before 4.1.7 | 4.1.7 |
| Packagist | web-token/jwt-framework | before 3.4.10 | 3.4.10 |
| Packagist | web-token/jwt-library | from 4.0.0 · before 4.0.7 | 4.0.7 |
| Packagist | web-token/jwt-library | from 4.1.0 · before 4.1.7 | 4.1.7 |
| Packagist | web-token/jwt-library | before 3.4.10 | 3.4.10 |
Same product
Packagist: all recordsOther highest-scoring records for the same primary product.
- GHSA-5739-39v2-5754PHP JWT Library: RSA1_5 (RSAES-PKCS1-v1_5) decryption lacks implicit rejection, exposing a Bleichenbacher/Marvin padding oracle0Monitor
- GHSA-3prj-6hqw-cm82PHP JWT Library: PBES2-HS*+A*KW unwrap accepts an unbounded p2c iteration count, enabling CPU-amplification denial of service0Monitor
Remediation
Which version to upgrade to
Fix versions compiled from the vendor, package registries and Microsoft. Verify the vendor's note before upgrading.
| Product / package | Fixed version | Source |
|---|---|---|
| Packagist:web-token/jwt-bundle | 3.4.10 | Package registry (OSV) |
| Packagist:web-token/jwt-bundle | 4.0.7 | Package registry (OSV) |
| Packagist:web-token/jwt-bundle | 4.1.7 | Package registry (OSV) |
| Packagist:web-token/jwt-experimental | 3.4.10 | Package registry (OSV) |
| Packagist:web-token/jwt-experimental | 4.0.7 | Package registry (OSV) |
| Packagist:web-token/jwt-experimental | 4.1.7 | Package registry (OSV) |
| Packagist:web-token/jwt-framework | 3.4.10 | Package registry (OSV) |
| Packagist:web-token/jwt-framework | 4.0.7 | Package registry (OSV) |
| Packagist:web-token/jwt-framework | 4.1.7 | Package registry (OSV) |
| Packagist:web-token/jwt-library | 3.4.10 | Package registry (OSV) |
| Packagist:web-token/jwt-library | 4.0.7 | Package registry (OSV) |
| Packagist:web-token/jwt-library | 4.1.7 | Package registry (OSV) |
Exploit status
No known public exploit
No public exploit has been observed yet. That doesn't mean you're safe, only that the bar is a little higher.
Research context
For pentesters and researchers: attack profile, score disagreement, timeline, patch commits, credits, variant and chain candidates, bug bounty scope. All derived from existing data; no exploit code.
Timeline
From publication to today: proof of concept, Metasploit module, CISA KEV and fix record. Dates are as reported by the sources.
No dated events beyond publication.
Not on record for this CVE: EPSS history · patch commit or PR link · researcher credit · variant or chain candidate · public bounty program.
Technical details
Attack conditions
- Anyone who can reach it over the internet can trigger it.
- No account or password is required.
- No user action is required.
- Special conditions such as timing or configuration are required.
If successful
- Confidentiality
- Integrity
- Availability
- Attack vector
- Network
- Attack complexity
- High
- Privileges required
- None
- User interaction
- None
Weakness class (CWE)
CWE-345 · Insufficient Verification of Data AuthenticityCVSS vector
CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N/E:P
osv
Attack context
MITRE CAPEC attack patterns and ATT&CK techniques for this weakness class (CWE). A starting point for detection rules and threat hunting.
Attack patterns (CAPEC)
- JSON Hijacking (aka JavaScript Hijacking)CAPEC-111likelihood: High · High
- Cache PoisoningCAPEC-141likelihood: High · High
- DNS Cache PoisoningCAPEC-142likelihood: High · High
- Content SpoofingCAPEC-148likelihood: Medium · Medium
- Spoofing of UDDI/ebXML MessagesCAPEC-218Medium
- Application API Message Manipulation via Man-in-the-MiddleCAPEC-384Low
- Transaction or Event Tampering via Application API ManipulationCAPEC-385Medium
- Application API Navigation RemappingCAPEC-386Medium
Change log (2)
- Fix✗ → ✓
- CVSS8 → —
For records you follow, these changes also arrive as notifications. →
References
Show all references (2 more)Show less
Vendor advisories and official records. Exploit/PoC links are deliberately left out.