# 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: ```python 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 | Library | ID | Encoding that slipped the guard | Fixed | |---|---|---|---| | PyJWT | CVE-2026-102268 (Critical) | Whitespace-prefixed, CR-only or single-line PEM | 2.14.0 | | PyJWT | CVE-2026-102271 | DER-encoded public keys (since 2.4.0) | 2.14.0 | | PyJWT | CVE-2026-102272 | UTF-8 BOM before JWK JSON | 2.14.0 | | PyJWT | CVE-2026-102273 / GHSA-xgmm-8j9v-c9wx | Public JWK wrapped in a JWKS or array | 2.14.0 | | Authlib | CVE-2026-114615 / GHSA-7vr2-2fgp-9w7p | Leading 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.0 | 1.9.0 | | Authlib | — | OpenSSH public keys and certs loaded as `OctKey` | 1.9.5 | | joserfc | GHSA-vvgp-wfq3-pjxj | DER RSA public key imported as an oct key | 1.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`. ### 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 `RecursionError`s 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 [[Server-Side Request Forgery|SSRF]]. ## Testing / review ```bash 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. ## Related - [[Python Security]] - [[Python Web Framework Security]] - [[Python SAST Tools]] - [[JSON Web Tokens]] - [[JWT Algorithm Confusion]] - [[JWT None Algorithm]] - [[JWT Header Injection]] - [[JWT Secret Cracking]] - [[OAuth 2.0 Vulnerabilities]] - [[OpenID Connect Security]] ## Sources - [[raw/safeguard.sh/pyjwt-2-14-2-15-algorithm-confusion-advisories-explained-13229|PyJWT 2.14/2.15: algorithm confusion advisories explained]] - [[raw/github.com/pyjwt-accepts-public-jwk-containers-as-hmac-secrets-13578|PyJWT accepts public JWK containers as HMAC secrets]] - [[raw/github.com/pyjwt-public-key-jwk-accepted-as-hmac-secret-enables-forged-hs256-toke-13579|PyJWT public-key JWK accepted as HMAC secret]] - [[raw/osv.dev/pyjwt-pyjwk-accepts-empty-hmac-keys-cve-2026-102266-12778|PyJWT: PyJWK accepts empty HMAC keys (CVE-2026-102266)]] - [[raw/lists.suse.com/pyjwt-hmac-forgery-with-known-public-key-cve-2026-102268-security-upda-14378|PyJWT HMAC forgery with known public key (SUSE)]] - [[raw/lists.suse.com/suse-su-2026-5064-1-pyjwt-hmac-forgery-and-jwks-key-substitution-fixes-14666|SUSE-SU-2026:5064-1: PyJWT fixes]] - [[raw/lists.suse.com/suse-security-update-for-python-pyjwt-13230|SUSE security update for python-PyJWT]] - [[raw/brickell-tech.com/cve-2026-114615-authlib-jwt-algorithm-confusion-fix-bypass-13750|CVE-2026-114615: Authlib JWT algorithm confusion fix bypass]] - [[raw/github.com/authlib-accepts-empty-hmac-key-allowing-jws-jwt-forgery-cve-2026-11461-12634|Authlib accepts empty HMAC key]] - [[raw/github.com/authlib-accepts-openssh-keys-certs-as-hmac-secrets-14803|Authlib accepts OpenSSH keys/certs as HMAC secrets]] - [[raw/github.com/authlib-jwt-bearer-grant-accepts-assertions-for-wrong-audience-12635|Authlib JWT bearer grant accepts wrong audience]] - [[raw/github.com/authlib-unvalidated-request-uri-fetch-in-jar-leading-to-ssrf-12620|Authlib: unvalidated request_uri fetch in JAR (SSRF)]] - [[raw/github.com/joserfc-octkey-accepts-der-rsa-public-keys-as-hmac-secrets-hs256-forge-13751|joserfc OctKey accepts DER RSA public keys]] - [[raw/github.com/joserfc-list-valued-jti-accepted-by-exact-value-jwt-claim-validation-14525|joserfc: list-valued jti accepted]] - [[raw/github.com/python-jose-authentication-bypass-through-3-5-0-13577|python-jose authentication bypass through 3.5.0]] - [[raw/medium.com/breaking-jwt-validation-how-json-nulls-python-booleans-and-unhandled-e-12779|Breaking JWT Validation: JSON nulls, Python booleans]] - [[raw/dev.to/jwt-verification-bugs-pin-the-algorithm-then-prove-the-fix-14230|JWT verification bugs: pin the algorithm, then prove the fix]]