CVE-2026-102271: PyJWT: Public keys in DER form are accepted as HMAC secrets, bypassing the CVE-2022-29217 guard
PyJWT is a Python implementation of JSON Web Token standards. From 2.4.0 until 2.14.0, PyJWT HMACAlgorithm.preparekey is affected because asymmetric-key guard relies on textual markers that are absent from DER encoding. This occurs when an application mixes HMAC and asymmetric algorithms and supplies a DER public key as the shared verification key. As a result, PyJWT uses public DER bytes as an HMAC secret. Consequently, an attacker who knows the public key can forge authenticated HMAC tokens. This issue is fixed in version 2.14.0.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
PyJWTto a version that resolves this vulnerability.Fixed in 2.14.0
Event History
Frequently Asked Questions
Which deployments are exposed to token forgery?
Deployments using PyJWT from 2.4.0 through versions before 2.14.0 are exposed only when they mix HMAC and asymmetric algorithms and provide an asymmetric public key in DER encoding as the shared verification key. An attacker must know that public key, which is commonly obtainable, to forge HMAC-authenticated tokens.
Are applications that use only one algorithm family affected?
The described condition requires mixing HMAC and asymmetric algorithms. The provided information does not indicate exposure for applications that do not permit both algorithm types in the relevant verification flow.
What is the remediation?
Upgrade PyJWT to version 2.14.0, which fixes the issue. Until upgrading, avoid configurations that mix HMAC and asymmetric algorithms while using a DER-encoded public key as the verification key.