Python JWT Library Vulnerabilities

The 2024–2026 run of verification bypasses in PyJWT, Authlib, joserfc, python-jose and jwcrypto. Nearly all are one of three classes: a public key accepted as an HMAC secret, an empty HMAC key accepted, or Python type quirks in claim checks.

How it works

Python JOSE libraries try to defend against JWT Algorithm Confusion by guessing whether a key passed as an HMAC secret is really public-key material (PEM markers, JWK kty, SSH prefixes). Each guard is a denylist over encodings, and researchers keep finding encodings it misses. The exposure precondition is almost always in the caller’s code:

jwt.decode(tok, key, algorithms=["RS256", "HS256"])   # reachable by every confusion bug
jwt.decode(tok, public_key, algorithms=["RS256"], audience="api")   # never reachable

If an allow-list mixes HMAC with RS/ES/PS/EdDSA and the verification key is raw material, an attacker who knows the public key (which is public by definition) signs HS256 with it.

Bug classes and cases

Public key as HMAC secret

LibraryIDEncoding that slipped the guardFixed
PyJWTCVE-2026-102268 (Critical)Whitespace-prefixed, CR-only or single-line PEM2.14.0
PyJWTCVE-2026-102271DER-encoded public keys (since 2.4.0)2.14.0
PyJWTCVE-2026-102272UTF-8 BOM before JWK JSON2.14.0
PyJWTCVE-2026-102273 / GHSA-xgmm-8j9v-c9wxPublic JWK wrapped in a JWKS or array2.14.0
AuthlibCVE-2026-114615 / GHSA-7vr2-2fgp-9w7pLeading newline or space before PEM. The 1.3.1 fix for CVE-2024-37568 only checked the start of the input. Affects 1.3.1–1.8.01.9.0
Authlib—OpenSSH public keys and certs loaded as OctKey1.9.5
joserfcGHSA-vvgp-wfq3-pjxjDER RSA public key imported as an oct key1.7.6

PyJWT already “fixed” this class as CVE-2022-29217. The 2026 advisories are four new encodings past that marker-based check.

Empty HMAC key

  • PyJWT < 2.13.0, CVE-2026-102266: PyJWK/PyJWKSet accepted an empty oct key because that path skipped the empty-key check that raw bytes get.
  • Authlib CVE-2026-114616: OctKey.import_key and HMACAlgorithm accept a zero-length key, which produces deterministic, forgeable HS* signatures. The same bug exists in fast-jwt and ruby-jwt.
  • python-jose ≤ 3.5.0, CVE-2026-120459: HMACKey/CryptographyHMACKey accept zero-length secrets.

Claim validation and type quirks

  • jwcrypto ≤ 1.6.1: check_claims={"sub": None} uses None to mean “required, any value”. A payload containing JSON null satisfies the presence check and then returns early, which bypasses required iss/sub/aud/jti. Python bool/int equivalence (int(True) == 1) and unhandled exceptions add further bypass and DoS paths.
  • joserfc < 1.7.6 (GHSA-mcm9-p458-pjmc): a list-valued jti passed an exact-value check as list membership. RFC 7519 requires a string.
  • Authlib RFC 7523 bearer grant (GHSA-fch4-3c6x-j4gc): get_audiences() returning [] made verify_claims() accept any aud.
  • PyJWT non-canonical signatures (Ubuntu USN-9177-1, November 2026): PyJWT accepted non-canonical encodings of the signature segment, which the advisory says could let an attacker bypass token revocation checks; fixed in updated packages. The advisory gives no mechanism; the likely one is that a single valid token gains several string forms, defeating denylists keyed on the raw token (Ubuntu).

JWKS fetching and DoS

  • PyJWT PyJWKClient: follows redirects on JWKS fetch (CVE-2026-102267), refetches on every unknown kid (CVE-2026-101917), lets one bad RSA key abort the whole set (CVE-2026-102274), and has ReDoS in is_pem_format (CVE-2026-102270). There are RecursionErrors on nested headers (CVE-2026-102265, CVE-2026-101918) that escape except jwt.PyJWTError and cause a 500 or a dead worker. decode() also mutated a reused options dict (CVE-2026-103001). Upgrade to PyJWT ≥ 2.15.0 for all 14.
  • Authlib JAR (RFC 9101): request_uri passed unvalidated to the fetch hook, giving unauthenticated SSRF.

Testing / review

pip show pyjwt authlib joserfc python-jose jwcrypto | grep -E '^(Name|Version)'
grep -rnE "algorithms\s*=\s*\[[^]]*HS[0-9]+[^]]*(RS|ES|PS|EdDSA)" --include=*.py .
grep -rnE 'verify_signature|get_unverified_header|options=' --include=*.py .
  • Is the algorithm list built dynamically, or from the token header? Either one means confusion is reachable.
  • Is options={"verify_signature": False} used on a request path? That is decode without verification.
  • Is the HS secret ≥ 256 bits and not a password (RFC 7518 §3.2, RFC 8725 §3.5)? See JWT Secret Cracking.
  • Send tokens with null claims, list-valued claims and empty-key HS256 signatures.

Defenses

  • Pin one algorithm per issuer from trusted config. Never mix HMAC and asymmetric in one decode().
  • Use typed key objects, not raw strings, and keep HMAC secrets and public keys in separate stores.
  • Require iss, aud and exp explicitly, and catch broad exceptions around decode.
  • Pin PyJWT explicitly in lockfiles because it often arrives transitively.

Sources