Executive brief
PyJWT is a popular Python library used to handle digital identity tokens (JWTs) for user authentication and authorization. A security flaw allows attackers to bypass security checks by tricking the system into using a public key as a secret password. This could allow an unauthorized person to forge identity tokens and gain full access to user accounts or administrative functions.
Technical details
A vulnerability in PyJWT's token verification logic allows for a JWT algorithm confusion attack. When a verifier is configured to allow both symmetric (HMAC) and asymmetric (RSA/ECDSA) algorithms and receives a public key in JSON Web Key (JWK) format, the library fails to prevent the JWK from being used as the shared secret for HMAC verification. An attacker can craft a token using the 'HS256' algorithm signed with the issuer's public JWK string. If the application passes this JWK to the decode function while allowing mixed algorithm families, the signature will validate, allowing for unauthenticated token forgery and identity impersonation. This bypasses existing protections that only check for PEM and SSH key formats.
Affected products
- jpadilla PyJWT < 2.13.0
Timeline
- 2026-05-21: disclosed: Initial disclosure on GitHub
- 2026-05-28: advisory: NVD publication
- 2026-06-15: patched: Version 2.13.0 released