CVE-2026-102268: PyJWT: Asymmetric-PEM detection bypass: whitespace/line-ending-mutated public keys skip the HS/asymmetric confusion guard
PyJWT is a Python implementation of JSON Web Token standards. Prior to 2.14.0, ispemformat in jwt/utils.py is affected because ispemformat does not recognize every PEM representation accepted by the cryptography loader. This occurs when an application mixes HMAC and asymmetric algorithms and supplies a mutated public-key PEM as raw key bytes. As a result, HMACAlgorithm.preparekey treats the unrecognized asymmetric public key 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 before 2.14.0 are exposed when they mix HMAC and asymmetric algorithms and pass a whitespace- or line-ending-mutated asymmetric public-key PEM as raw key bytes. An attacker must know the public key, which is commonly not secret.
What is the underlying exploitation condition?
The mutated PEM must be accepted by the cryptography loader while not being recognized by PyJWT's is_pem_format check. PyJWT then treats the asymmetric public key as an HMAC secret, allowing the attacker to forge HMAC-authenticated tokens.
What should be done to remediate the issue?
Upgrade PyJWT to version 2.14.0. Until upgrading, avoid configurations that mix HMAC and asymmetric algorithms and avoid supplying mutated public-key PEM material as raw key bytes.