CVE-2026-102272
UTF-8 BOM in public JWK bypasses asymmetric check, allowing 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, HMACAlgorithm.prepare_key in jwt/algorithms.py is affected because raw-JWK detector does not normalize accepted Unicode byte-order marks before checking for JSON. This occurs when a public JWK is prefixed with a UTF-8 BOM and used in a mixed-algorithm verification path. As a result, public JWK bypasses asymmetric-key detection and becomes the HMAC secret. Consequently, an attacker who knows the public key can forge authenticated tokens. This issue is fixed in version 2.14.0.
- CWE
- CWE-347
- CVSS base score
- 7.4
- Published
- 2026-09-28
- OWASP
- A07 Identification and Authentication Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Incorrect 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_json: str) -> dict:
"""
Verify a JWT using a JWK that may be prefixed with a UTF-8 BOM.
The mixed-algorithm list allows an attacker to force HMAC verification
when the JWK is interpreted as a raw secret.
"""
# VULNERABLE: raw JWK with BOM is passed unchanged, bypassing asymmetric detection
key = jwk_json # jwt.algorithms.HMACAlgorithm.prepare_key will accept it as secret
return jwt.decode(token, key, algorithms=["HS256", "RS256"])Patched code sample
import jwt
def verify_token(token: str, jwk_json: str) -> dict:
"""
Verify a JWT using a JWK that may be prefixed with a UTF-8 BOM.
The mixed-algorithm list is retained, but the BOM is stripped so the JWK
is correctly interpreted as an asymmetric key.
"""
# FIX: strip UTF-8 BOM before handing the JWK to the library
key = jwk_json.lstrip("\ufeff")
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.
- Reject encoded JWKs as HMAC keys (jpadilla/pyjwt)
jwt/algorithms.py · HMACAlgorithm.prepare_key
Cite this entry
@misc{vaitp:cve2026102272,
title = {{UTF-8 BOM in public JWK bypasses asymmetric check, allowing token forgery}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-102272},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-102272/}}
}
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 ::
