CVE-2026-102275
PyJWT OKP JWK mismatch lets attackers misuse stolen tokens (2.1.0‑2.15.0).
- CVSS 8.2
- CWE-345
- Input Validation and Sanitization
- Remote
PyJWT is a Python implementation of JSON Web Token standards. From 2.1.0 until 2.15.0, PyJWT OKPAlgorithm.from_jwk in jwt/algorithms.py is affected because private-JWK import path does not compare the public key derived from d with x. This occurs when an OKP private JWK supplies non-corresponding x and d components. As a result, identity derived from x can differ from operations performed with d. Consequently, if an integration also accepts private key parameters from a proof header without rejecting them, an attacker may use a stolen sender-constrained token without the legitimate private key. This issue is fixed in version 2.15.0.
- CWE
- CWE-345
- CVSS base score
- 8.2
- Published
- 2026-09-28
- OWASP
- A02 Cryptographic Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Unauthorized Access
- Affected component
- PyJWT
- Fixed by upgrading
- Yes
Solution
Upgrade PyJWT to version 2.15.0 or later.
Vulnerable code sample
import jwt
from jwt.algorithms import OKPAlgorithm
def sign_with_jwk(payload: dict, jwk: dict) -> str:
# VULNERABLE: accepts mismatched private/public components in OKP JWK
alg = OKPAlgorithm.from_jwk(jwk)
token = jwt.encode(payload, key=alg, algorithm=alg.name)
return tokenPatched code sample
import jwt
from jwt.algorithms import OKPAlgorithm
from cryptography.hazmat.primitives.asymmetric import ed25519
from cryptography.hazmat.primitives import serialization
def sign_with_jwk(payload: dict, jwk: dict) -> str:
# FIX: verify that public key 'x' matches private key 'd' before use
if jwk.get("kty") != "OKP" or jwk.get("crv") != "Ed25519":
raise ValueError("Unsupported JWK type")
d_bytes = jwt.utils.base64url_decode(jwk["d"])
x_bytes = jwt.utils.base64url_decode(jwk["x"])
private_key = ed25519.Ed25519PrivateKey.from_private_bytes(d_bytes)
derived_x = private_key.public_key().public_bytes(
encoding=serialization.Encoding.Raw,
format=serialization.PublicFormat.Raw,
)
if derived_x != x_bytes:
raise ValueError("JWK 'x' does not match the public key derived from 'd'")
alg = OKPAlgorithm.from_jwk(jwk)
token = jwt.encode(payload, key=alg, algorithm=alg.name)
return tokenPublished 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 inconsistent OKP private keys (jpadilla/pyjwt)
jwt/algorithms.py
Cite this entry
@misc{vaitp:cve2026102275,
title = {{PyJWT OKP JWK mismatch lets attackers misuse stolen tokens (2.1.0‑2.15.0).}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-102275},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-102275/}}
}
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 ::
