CVE-2026-102266
Empty “k” value in JWK lets attackers forge HMAC JWTs with zero‑length key.
- CVSS 9.1
- CWE-347
- Authentication, Authorization, and Session Management
- Remote
PyJWT is a Python implementation of JSON Web Token standards. From 2.13.0 until 2.14.0, HMACAlgorithm.from_jwk is affected because PyJWK verification path used the decoded key without applying prepare_key validation. This occurs when a trusted JWK Set contains an oct entry with an empty k value. As a result, an attacker signs an HMAC token with the same zero-length key accepted by PyJWT. Consequently, forged token can carry arbitrary authenticated claims. This issue is fixed in version 2.14.0.
- CWE
- CWE-347
- CVSS base score
- 9.1
- Published
- 2026-09-28
- OWASP
- A02 Cryptographic Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Authentication, Authorization, and Session Management
- Subcategory
- Insecure Authentication Mechanisms
- Accessibility scope
- Remote
- Impact
- Unauthorized Access
- Affected component
- PyJWT
- Fixed by upgrading
- Yes
Solution
Upgrade PyJWT to version 2.14.0 (or later).
Vulnerable code sample
import jwt
def verify_token(token: str, jwk_set: dict) -> dict:
# VULNERABLE: using empty HMAC key from JWK without validation
empty_jwk = next(j for j in jwk_set.get("keys", []) if j.get("k", None) == "")
key_bytes = jwt.algorithms.HMACAlgorithm.from_jwk(empty_jwk)
return jwt.decode(token, key=key_bytes, algorithms=["HS256"])Patched code sample
import jwt
def verify_token(token: str, jwk_set: dict) -> dict:
# FIX: use PyJWKClient which validates the JWK before extracting the key
client = jwt.PyJWKClient("")
client._jwks_data = jwk_set # inject the provided JWK set
jwk = client.get_signing_key_from_jwt(token)
return jwt.decode(token, key=jwk.key, algorithms=["HS256"])Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Validate PyJWK HMAC keys consistently (jpadilla/pyjwt)
jwt/api_jws.py · PyJWS._verify_signature
Cite this entry
@misc{vaitp:cve2026102266,
title = {{Empty “k” value in JWK lets attackers forge HMAC JWTs with zero‑length key.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-102266},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-102266/}}
}
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 ::
