A vulnerability in the web-token jwt-library before versions 3.4.13, 4.0.9, 4.1.11, and 4.2.6 allows an attacker with the recipient's public key to exploit a decryption oracle in the RSACrypt::decryptWithRSAOAEP() function. This flaw permits recovery of the Content Encryption Key (CEK) byte by byte by submitting crafted encrypted keys composed of multiple RSA blocks, enabling decryption of captured JSON Web Encryption (JWE) tokens. The issue affects multiple versions across the 2.x, 3.x, and 4.x branches and has been assigned a CVSS 4.0 score of 6.3 (medium severity).
CVE-2026-137559 is a high-severity vulnerability in the web-token jwt-library that allows unauthenticated attackers to cause CPU exhaustion. This occurs because, on PHP installations without GMP, the AbstractECDH component falls back to inefficient pure PHP code that processes unbounded ECDH-ES epk x and y coordinates without length checks. Attackers can exploit this by sending small JSON Web Encryption (JWE) tokens with oversized epk coordinates, causing significant processing delays and resource consumption.
CVE-2026-137560 is a denial of service vulnerability in the web-token jwt-library affecting versions before 3.4.13, 4.0.9, 4.1.11, and 4.2.6. The flaw exists in RSAKey, which accepts RSA keys with unbounded modulus and public exponent lengths. An attacker can supply a crafted key to cause excessive CPU consumption during RSA operations, including signature verification and encryption, especially when GMP is unavailable.
CVE-2026-137561 affects the web-token jwt-library and jwt-framework in multiple versions before 3.4.13, 4.0.9, 4.1.11, and 4.2.6. The vulnerability is a token malleability flaw where the JWEDecrypter does not reject a non-empty JWE Encrypted Key for certain algorithms, allowing attackers to create multiple distinct token strings from one token that still decrypt correctly. This can bypass replay caches, single-use registries, or revocation deny-lists that rely on token string uniqueness.
The web-token jwt-framework versions before 3.4.13, 4.0.9, 4.1.11, and 4.2.6 do not properly validate the length of octet keys used in certain AES and chacha20-poly1305 key encryption algorithms. This flaw causes OpenSSL to zero-pad short or empty keys, allowing attackers to unwrap content encryption keys when an empty key is used. Consequently, attackers can read issued tokens and forge accepted tokens.
A vulnerability in the web-token jwt-framework versions 4.2.1 through before 4.2.6 allows information disclosure via error messages. Specifically, when JWE tokens are rejected, exception stack traces may expose sensitive decryption keys such as directory, AES key wrapping, PBES2-derived, or content encryption keys. This occurs because crafted JWE tokens cause JWELoader and JWEDecrypter to log these keys in trace arguments accessible to others.
CVE-2026-137564 affects the web-token jwt-library versions before 3.4.13, 4.0.x before 4.0.9, 4.1.x before 4.1.11, and 4.2.x before 4.2.6, as well as jwt-encryption through 3.2.10. The vulnerability arises because the library does not properly check key length in JWEBuilder and JWEDecrypter for direct encryption, leading to zero-padding of undersized keys. This allows attackers holding tokens issued with half-size AES-CBC-HMAC keys to decrypt them, and empty keys enable forging tokens accepted by the decrypter.
A timing side-channel vulnerability exists in the web-token jwt-library and jwt-core components before specified fixed versions. The vulnerability arises from unblinded RSA private key operations in the RSAKey::exponentiate() function, allowing attackers who can submit JSON Web Encryption (JWE) tokens to measure decryption timing differences. These timing discrepancies enable attackers to perform a binary search on the RSA prime q, potentially factoring the RSA modulus and decrypting all JWEs encrypted with the affected key.
CVE-2026-137580 is a high-severity vulnerability in the web-token jwt-library affecting multiple versions before 3.4.13, 4.0.9, 4.1.11, and 4.2.6. The vulnerability arises from an inefficient algorithmic complexity in parsing JSON General serialized JWS tokens, leading to quadratic time processing. This allows unauthenticated remote attackers to send large tokens with thousands of empty signatures, exhausting CPU resources and occupying PHP workers without needing valid keys or tokens.
CVE-2026-137581 is a denial of service vulnerability in the web-token jwt-library and related components. It affects multiple versions prior to 3.4.13, 4.0.9, 4.1.11, and 4.2.6. The vulnerability arises because the JWS and JWE serializers pass attacker-controlled tokens and protected headers to json_decode() without bounds before verification. This allows unauthenticated attackers to submit large tokens with colliding header member names or deeply nested arrays, causing quadratic decoding time or fatal memory exhaustion.
CVE-2026-137582 is a high-severity denial of service vulnerability in the web-token jwt-framework. Versions before 3.4.13, 4.0.x before 4.0.9, 4.1.x before 4.1.11, and 4.2.x before 4.2.6 are affected. The issue arises because JWELoader and JWSLoader attempt to process every recipient or signature in a JSON General serialized token without limiting their number. An unauthenticated attacker can exploit this by sending a small JWE with many empty recipients, each with a maximal PBES2 p2c value, causing repeated expensive key derivations that exhaust CPU resources.
A vulnerability exists in web-token jwt-framework and jwt-library versions before 3.4.12, 4.0.x before 4.0.8, 4.1.x before 4.1.10, and 4.2.x before 4.2.4, as well as jwt-encryption-algorithm-ecdh-es through 3.2.10. The ConcatKDF::generate() function uses a single SHA-256 round to derive keys for ECDH-ES and ECDH-SS direct key agreement, limiting derived key length to 32 bytes. This flaw allows decryption of JWE tokens using A256CBC-HS512 under an all-zero AES key, and reduces the strength of A192CBC-HS384 content keys to 64 bits.
The PHP JWT Library's RSA1_5 decryption implementation lacks the required implicit rejection countermeasure for RSAES-PKCS1-v1_5 padding, enabling a Bleichenbacher/Marvin padding oracle attack. This allows attackers to distinguish padding errors through timing side channels and potentially recover the wrapped content encryption key (CEK). The vulnerability affects applications using RSA1_5 with an RSA private key. A patch is available that implements constant-time implicit rejection, neutralizing the oracle. Users are advised to migrate to RSA-OAEP algorithms and avoid enabling RSA1_5 for untrusted tokens.
## 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`.
The PHP JWT Library contains a vulnerability in its PBES2-HS*+A*KW key unwrapping implementation where the iteration count parameter (p2c) from the attacker-controlled JOSE header is not properly bounded. This allows an unauthenticated attacker to specify an extremely large iteration count, causing excessive CPU consumption during PBKDF2 computation and resulting in a denial of service. The vulnerability affects applications that enable PBES2 algorithms for decryption. A patch has been introduced that enforces a configurable maximum iteration count to prevent CPU amplification attacks.