pypi / pyjwt
pyjwt
What changed in pyjwt 1 to 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-12-05.
18 breaking20 security7 new APIs and options5 behavior and defaults1 tooling7 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initpyjwt 252 changes
Breaking changes 16
The encoder adds b64 to crit, and the decoder rejects b64=false tokens that omit it.
Requires the compact-form payload segment to be empty for detached-payload JWS and no longer decodes that unused segment.
Rejects JWK-shaped JSON strings as HMAC keys, preventing algorithm confusion when symmetric and asymmetric algorithms are both allowed.
Empty HMAC keys now raise InvalidKeyError instead of being accepted with a warning.
Verification now requires the token header alg to match the algorithm bound to the PyJWK.
Rejects URIs whose scheme is not http or https, preventing access through unintended schemes.
The RFC 7515 crit header parameter is validated, affecting how tokens with critical header parameters are handled.
The included CLI entry point is removed.
The cryptography package is now required at version 3 or later.
The ECDSA package is no longer supported as a cryptographic backend.
Encoded tokens are returned as strings rather than bytes.
PyCrypto is no longer supported as a cryptographic backend.
The unused verify argument is removed from PyJWS.decode().
PyJWT.encode() no longer mutates the input payload.
Python 2 is no longer supported.
Support for Python 3.5 is removed.
Security 18
PyJWT accepts inconsistent OKP x/d JWKs, causing public/private key identity confusion
PyJWT: Unauthenticated RecursionError DoS in pre-verification payload parse (PyJWKClient.get_signing_key_from_jwt / verify_signature=False)
PyJWT accepts public JWK containers as HMAC secrets
PyJWT: Asymmetric-PEM detection bypass: whitespace/line-ending-mutated public keys skip the HS/asymmetric confusion guard
PyJWT BOM Bypass
PyJWT: HS256/384/512 verify accepts empty HMAC key via oct JWK (PyJWK/PyJWKClient) enabling token forgery
PyJWT: Malformed RSA JWK aborts parsing of an entire JWK Set
PyJWT: Non-canonical signature segments enable raw-token revocation bypass
PyJWT: Public keys in DER form are accepted as HMAC secrets, bypassing the CVE-2022-29217 guard
PyJWT: PyJWK accepts empty HMAC keys, bypassing PyJWT's empty-key validation
PyJWT: PyJWKClient follows redirects when fetching JWKS
PyJWT: PyJWKClient still amplifies unauthenticated JWKS fetches on unknown kid values (incomplete fix of CVE-2026-48524)
PyJWT: ReDoS vulnerability when calling the
is_pem_formatfunction.PyJWT: Uncaught RecursionError in jwt.decode() on deeply nested token header
A failed fetch no longer evicts valid cached JWK sets, so transient endpoint errors do not cause application-wide authentication failure.
Per-call options are forwarded to signature verification, so enforce_minimum_key_length now takes effect when passed to decode.
Keys are validated against the allowed types for their algorithm family.
Issuer claim type checks are added.
New APIs and options 7
PyJWKSet gains an iterator, allowing developers to iterate over its keys.
Adds support for JWKs containing ECDSA keys.
Adds support for Ed25519 / EdDSA.
InvalidKeyError is exposed on the jwt module.
Introduces PyJWK for working with JWKs.
Introduces PyJWKClient for retrieving signing keys from a JWK endpoint.
Introduces PyJWKSet for working with JWK sets.
Behavior and default changes 3
Encoding without an explicit algorithm now uses the PyJWK algorithm.
Passing algorithm=None is mapped to the "none" algorithm.
The decode return type is dict[str, Any].
Tooling 1
The PyJWKSet.keys annotation was updated for pyright.
Fixes and other changes 7
Adds typing_extensions as a dependency for Python versions below 3.11.
HTTPError is closed to prevent a ResourceWarning on Python 3.14.
PyJWK no longer stores a reference to the algorithms dict.
The options parameter's typing and logic are improved in decode and decode_complete.
The lifespan and timeout type annotations use float instead of int.
The method's type annotation is corrected.
PyJWT adds support for Python 3.14.
pyjwt 16 changes
Breaking changes 2
The api.header API was removed.
Functions from api.py were refactored into a PyJWT object, changing how developers access the API.
Security 2
The release fixes vulnerabilities that could let attackers bypass verification by exploiting algorithm and key choice, including tokens with an unvalidated alg header.
Whitelist validation of the alg header is supported, helping developers validate which algorithms a token may use.
Behavior and default changes 2
ecdsa is supported when cryptography isn't available.
PyCrypto is supported when cryptography isn't available.