Impact
PyJWT’s HMACAlgorithm.prepare_key erroneously accepts a public JWK container as the secret key when the library is used with both HMAC and asymmetric algorithms. The HMAC key guard fails to recognize container representations, allowing public key material to be treated as symmetric secret data. An attacker who can obtain the public key can forge a JWT that carries arbitrary claims and present it to a system that trusts the token. This flaw corresponds to CWE‑347 because the implementation incorrectly validates the key format, enabling an attacker to hijack the token’s authentication logic.
Affected Systems
The vulnerability is present in PyJWT 2.13.x, including 2.13.0 through all 2.13.x releases, and is fixed starting with version 2.14.0. The affected vendor is jpadilla:pyjwt; any Python application that incorporates this library and allows both HMAC and asymmetric algorithms without proper key handling is susceptible.
Risk and Exploitability
The CVSS score of 7.4 indicates a high impact. EPSS is not available, and the vulnerability has not been listed in the CISA KEV catalog, suggesting no reported exploits yet. The attack vector is inferred to be application‑level; an attacker only needs to supply a JWT signed with the compromised public key or manipulate token creation logic. Once a forged token is accepted, the attacker gains the privileges encoded in the token, potentially allowing full system compromise if the token is used for authentication.
OpenCVE Enrichment
Github GHSA