HighGHSA-r9jw-mwhq-wp62CVE-2017-11424PYSEC-2017-24

PyJWT vulnerable to key confusion attacks

Published 13 May 2022 · Updated 5 Dec 2024

Is your project on an affected pyjwt?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Look after several Python apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Affected package

pyjwtPyPI
Affected
<1.5.1
Fixed in
1.5.1
Update to the fixed version for your release line, for example:pip install 'pyjwt>=1.5.1'

Details

In PyJWT 1.5.0 and below the invalid_strings check in HMACAlgorithm.prepare_key does not account for all PEM encoded public keys. Specifically, the PKCS1 PEM encoded format would be allowed because it is prefaced with the string -----BEGIN RSA PUBLIC KEY----- which is not accounted for. This enables symmetric/asymmetric key confusion attacks against users using the PKCS1 PEM encoded public keys, which would allow an attacker to craft JWTs from scratch.

Is GHSA-r9jw-mwhq-wp62 in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected pyjwt, and gives you the command that fixes it.

More advisories for pyjwt

  • HighGHSA-pxh4-856f-4h89PyJWT: HS256/384/512 verify accepts empty HMAC key via oct JWK (PyJWK/PyJWKClient) enabling token forgery · 22 Oct 2026
  • MediumCVE-2026-102275PyJWT accepts inconsistent OKP x/d JWKs, causing public/private key identity confusion · 5 Oct 2026
  • MediumCVE-2026-103001PyJWT.decode() reintroduces options-dict mutation, enabling silent claim-verification bypass on dict reuse · 30 Sept 2026
  • MediumCVE-2026-101918PyJWT: Unauthenticated RecursionError DoS in pre-verification payload parse (PyJWKClient.get_signing_key_from_jwt / verify_signature=False) · 30 Sept 2026
  • MediumCVE-2026-102270PyJWT: ReDoS vulnerability when calling the `is_pem_format` function. · 30 Sept 2026
  • HighCVE-2026-102266PyJWT: PyJWK accepts empty HMAC keys, bypassing PyJWT's empty-key validation · 29 Sept 2026
All 25 advisories for pyjwt

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.