CVE-2026-120459
Zero‑length HMAC secret lets attackers forge JWTs, bypassing authentication.
- CVSS 9.1
- CWE-347
- Cryptographic
- Remote
python-jose through 3.5.0 contains an authentication bypass vulnerability that allows unauthenticated attackers to forge JWTs because HMACKey and CryptographyHMACKey accept zero-length HMAC secrets. When an application's HS256/HS384/HS512 verification key resolves to empty, such as an oct JWK with empty k, attackers can forge tokens with arbitrary claims that jwt.decode accepts.
- CWE
- CWE-347
- CVSS base score
- 9.1
- Published
- 2026-11-02
- OWASP
- A02 Cryptographic Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Cryptographic
- Subcategory
- Cryptographic Implementation Error
- Accessibility scope
- Remote
- Impact
- Unauthorized Access
- Affected component
- python-jose
- Fixed by upgrading
- Yes
Solution
Upgrade python‑jose to version 3.5.1 or later.
Vulnerable code sample
import json
from jose import jwt, JWTError
from jose.backends.base import Key
from jose.backends.hmac import HMACKey
def verify_token(token: str, jwk: dict) -> dict:
# VULNERABLE: accepts empty HMAC secret, allowing forgery
key = HMACKey(jwk.get('k', ''), algorithm=jwk.get('alg', 'HS256'))
try:
payload = jwt.decode(token, key, algorithms=[key.algorithm])
return payload
except JWTError as e:
raise ValueError("Invalid token") from ePatched code sample
import json
from jose import jwt, JWTError
from jose.backends.base import Key
from jose.backends.hmac import HMACKey
def verify_token(token: str, jwk: dict) -> dict:
# FIX: reject empty HMAC secret before constructing key
secret = jwk.get('k', '')
if not secret:
raise ValueError("Empty HMAC secret not allowed")
key = HMACKey(secret, algorithm=jwk.get('alg', 'HS256'))
try:
payload = jwt.decode(token, key, algorithms=[key.algorithm])
return payload
except JWTError as e:
raise ValueError("Invalid token") from eCite this entry
@misc{vaitp:cve2026120459,
title = {{Zero‑length HMAC secret lets attackers forge JWTs, bypassing authentication.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-120459},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-120459/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
