7.5high
joserfc PBES2 p2c Unbounded Iteration Count enables Denial of Service (DoS)
- Severity
- 7.5high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.46% (higher than 41% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-w5r5-m38g-f9f9PYSEC-2026-2529
Description
joserfc is a Python library that provides an implementation of several JSON Object Signing and Encryption (JOSE) standards. In 1.6.2 and earlier, a resource exhaustion vulnerability in joserfc allows an unauthenticated attacker to cause a Denial of Service (DoS) via CPU exhaustion. When the library decrypts a JSON Web Encryption (JWE) token using Password-Based Encryption (PBES2) algorithms, it reads the p2c (PBES2 Count) parameter directly from the token's protected header. This parameter defines the number of iterations for the PBKDF2 key derivation function. Because joserfc does not validate or bound this value, an attacker can specify an extremely large iteration count (e.g., 2^31 - 1), forcing the server to expend massive CPU resources processing a single token. This vulnerability exists at the JWA layer and impacts all high-level JWE and JWT decryption interfaces if PBES2 algorithms are allowed by the application's policy.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| authlib joserfc | <= 1.6.2 | CVE List |
| joserfc (PyPI) | before 1.6.3 | GitHub Advisory Database, PyPA Advisory Database |
| hsiaoming joserfc | up to 1.6.2 | NVD |
All scores
| GitHub_M | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| GitHub | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| PyPA Advisory Database | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
Classification
SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.
What each source says
CVE List
joserfc is a Python library that provides an implementation of several JSON Object Signing and Encryption (JOSE) standards. In 1.6.2 and earlier, a resource exhaustion vulnerability in joserfc allows an unauthenticated attacker to cause a Denial of Service (DoS) via CPU exhaustion. When the library decrypts a JSON Web Encryption (JWE) token using Password-Based Encryption (PBES2) algorithms, it reads the p2c (PBES2 Count) parameter directly from the token's protected header. This parameter defines the number of iterations for the PBKDF2 key derivation function. Because joserfc does not validate or bound this value, an attacker can specify an extremely large iteration count (e.g., 2^31 - 1), forcing the server to expend massive CPU resources processing a single token. This vulnerability exists at the JWA layer and impacts all high-level JWE and JWT decryption interfaces if PBES2 algorithms are allowed by the application's policy.
GitHub Advisory Database
Summary
A resource exhaustion vulnerability in joserfc allows an unauthenticated attacker to cause a Denial of Service (DoS) via CPU exhaustion. When the library decrypts a JSON Web Encryption (JWE) token using Password-Based Encryption (PBES2) algorithms, it reads the p2c (PBES2 Count) parameter directly from the token's protected header. This parameter defines the number of iterations for the PBKDF2 key derivation function. Because joserfc does not validate or bound this value, an attacker can specify an extremely large iteration count (e.g., 2^31 - 1), forcing the server to expend massive CPU resources processing a single token.
This vulnerability exists at the JWA layer and impacts all high-level JWE and JWT decryption interfaces if PBES2 algorithms are allowed by the application's policy.
Details
Vulnerable file: src/joserfc/_rfc7518/jwe_algs.py
Vulnerable function: PBES2HSAlgKeyEncryption.decrypt_cek()
Lines: 283
def decrypt_cek(self, recipient: Recipient[OctKey]) -> bytes:
headers = recipient.headers()
# ...
p2c = headers["p2c"] # ← attacker-controlled integer
# ...
kek = self.compute_derived_key(key.get_op_key("deriveKey"), p2s, p2c)
The p2c value is then passed to compute_derived_key :
def compute_derived_key(self, key: bytes, p2s: bytes, p2c: int) -> bytes:
# ...
kdf = PBKDF2HMAC(
algorithm=self.hash_alg,
length=self.key_size // 8,
salt=salt,
iterations=p2c, # ← unbounded iterations
backend=default_backend(),
)
Impact on JWT Policies
Any JWT policy configured to allow PBES2 key management algorithms (e.g., PBES2-HS256+A128KW) is vulnerable. Because the DoS occurs during the decryption phase, the attack is triggered before any claim validation (e.g.,
exp,iss, aud checks) or nested signature verification takes place. This makes existing JWT "policies" ineffective as a defense if the underlying algorithm is permitted.
PoC
Tested against joserfc 1.6.2. Local Reproduction:
import time
from joserfc import jwe
from joserfc.jwk import OctKey
# Force joserfc to use local source if needed
# sys.path.insert(0, "src")
# Attacker-crafted token with 10 million iterations
# Normally legitimate p2c is ~2048-4096. 10M iterations = ~5s DoS.
token = "eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwicDJzIjoiWjI5dVpYSm1ZdyIsInAyYyI6MTAwMDAwMDB9.dummy.dummy.dummy.dummy"
key = OctKey.import_key(b"any-password")
t0 = time.perf_counter()
try:
# This call will hang the thread for seconds
jwe.decrypt_compact(token, key, algorithms=["PBES2-HS256+A128KW", "A128CBC-HS256"])
except Exception:
pass
print(f"Elapsed: {time.perf_counter() - t0:.2f}s")
Impact
An unauthenticated remote attacker can exhaust the CPU resources of a server by sending a small number of crafted JWE/JWT tokens. Each token will occupy a worker thread/process for a duration proportional to the p2c value (up to several minutes or hours depending on the integer value). This results in a complete Denial of Service for legitimate users.
Recommendation
Minimal fix: Implement an upper bound check for the p2c parameter in PBES2HSAlgKeyEncryption.decrypt_cek().
MAX_P2C = 300000 # Example security bound
# ... inside decrypt_cek ...
p2c = headers["p2c"]
if not isinstance(p2c, int) or p2c > MAX_P2C:
raise DecodeError(f"p2c iteration count too high (max {MAX_P2C})")
Additionally, applications should only enable PBES2 algorithms if password-based encryption is specifically required and should enforce a strict algorithms allowlist in their JWT/JWE policies.
NVD (es)
joserfc es una librería de Python que proporciona una implementación de varios estándares JSON Object Signing and Encryption (JOSE). En 1.6.2 y versiones anteriores, una vulnerabilidad de agotamiento de recursos en joserfc permite a un atacante no autenticado causar una denegación de servicio (DoS) mediante el agotamiento de la CPU. Cuando la librería descifra un token JSON Web Encryption (JWE) utilizando algoritmos de cifrado basado en contraseña (PBES2), lee el parámetro p2c (PBES2 Count) directamente del encabezado protegido del token. Este parámetro define el número de iteraciones para la función de derivación de clave PBKDF2. Debido a que joserfc no valida ni limita este valor, un atacante puede especificar un número de iteraciones extremadamente grande (por ejemplo, 2^31 - 1), forzando al servidor a gastar recursos masivos de CPU al procesar un solo token. Esta vulnerabilidad existe en la capa JWA y afecta a todas las interfaces de descifrado JWE y JWT de alto nivel si los algoritmos PBES2 están permitidos por la política de la aplicación.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-27932 changed 2026-03-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-w5r5-m38g-f9f9 changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2026-27932 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2026-2529 changed 2026-07-13 | CC-BY-4.0 |