CVE-2026-102273
Public JWK container accepted as HMAC secret, enabling token forgery.
- CVSS 7.4
- 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, PyJWT HMACAlgorithm.prepare_key is affected because HMAC key guard only recognizes top-level public JWK forms and misses container representations. This occurs when an application allows HMAC and asymmetric algorithms and passes a public JWK container as the raw key. As a result, public asymmetric key material is accepted as the HMAC secret. Consequently, an attacker who knows the public key can forge a token with arbitrary authenticated claims. This issue is fixed in version 2.14.0.
- CWE
- CWE-347
- CVSS base score
- 7.4
- 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, key):
# VULNERABLE: accepts public JWK as HMAC secret
return jwt.decode(token, key, algorithms=["HS256", "RS256"])Patched code sample
import jwt
def verify_token(token: str, key):
# FIX: reject JWK objects for HMAC verification
if isinstance(key, dict):
raise TypeError("JWK objects must not be used as HMAC secret")
return jwt.decode(token, key, algorithms=["HS256", "RS256"])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.
- fix: reject public JWK container HMAC keys (jpadilla/pyjwt)
jwt/algorithms.py · HMACAlgorithm.prepare_key
Cite this entry
@misc{vaitp:cve2026102273,
title = {{Public JWK container accepted as HMAC secret, enabling token forgery.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-102273},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-102273/}}
}
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 ::
