PQ Python

FastAPI has no crypto of its own; its auth stack and TLS hops decide exposure

FastAPI contains no cryptography, so what needs changing depends on how your app signs or accepts tokens and where TLS terminates. Tokens signed with your own shared secret (HS256), HMAC-signed sessions and Argon2 password hashes need no change. Key-pair-signed JWTs, identity-provider tokens, passkeys, Web Push, stored public-key ciphertexts and every TLS hop do, and only jwcrypto has released ML-DSA JWTs.

State as of 3 Dec 2026

In short

  • FastAPI and Starlette contain no public-key cryptography. HS256 tokens signed with your own secret, Argon2 password hashes and HMAC-signed sessions need no change; key-pair-signed and identity-provider tokens do (find your pattern).
  • Each TLS hop (edge, origin or mesh, direct Uvicorn, outbound) has a different owner and must be configured and measured on its own (details).
  • Data encrypted to X25519 or P-256 keys, including JWE ECDH-ES and Web Push payloads, is harvestable today. Re-encrypt what you store (details).
  • For self-issued ES256 or EdDSA tokens, ES384 or RSA-3072+ is the stopgap. Only jwcrypto has released ML-DSA JWTs; PyJWT PR #1256 is unmerged (details).
  • Major IdPs sign with RSA-2048; Supabase and Sign in with Apple use P-256. Pin algorithms per issuer and test JWKS parsing against AKP keys (details).
  • An ML-DSA-65 JWT adds 4.2 KiB to every request and, like ML-DSA-87, does not fit a 4,096-byte cookie. Keep browser sessions opaque or HMAC-signed, and ML-DSA tokens in headers (details).
  • Columns sized for ECC keys reject or truncate ML-DSA keys, signatures and tokens, and SQLite-backed tests will not notice. Widen them before the first ML-DSA value arrives (details).

FastAPI and Starlette contain no public-key cryptography#

FastAPI 0.165.0 (18 Nov 2026) has no cryptographic code: its extracted wheel imports none of hashlib, hmac, ssl, cryptography, secrets, itsdangerous, jwt or jose (PyPI fastapi 0.165.0). Its fastapi/security/ package only extracts headers, cookies and forms and generates OpenAPI schemas. Bare FastAPI depends on Starlette, AnyIO, Pydantic and support packages, not on a TLS engine, PyJWT or cryptography; fastapi[standard] adds the CLI and uvicorn[standard], among others (FastAPI 0.165.1 metadata).

Starlette 1.10.0 (24 Oct 2026) has one cryptographic use, SessionMiddleware. It calls itsdangerous.TimestampSigner(str(secret_key)) and signs, but does not encrypt, base64-encoded JSON. itsdangerous defaults to HMAC via _lazy_sha1 with django-concat key derivation (sessions.py, itsdangerous signer.py). HMAC-SHA1 remains a secure MAC and is outside the advisory’s scope, and these sessions never promised confidentiality.

FastAPI’s OAuth2PasswordBearer extracts the bearer credential; it does not verify its signature or decide its permissions. Verification is up to your app or its auth library, so exposure depends on who signs your tokens and with what:

Your tokens are Typical setup Exposure Detail
Signed and verified by your own service with a shared secret (HS256) FastAPI’s official tutorial, with PyJWT; the fastapi-users, simplejwt and Flask-JWT-Extended defaults None HS256
Signed by your own service with a key pair (ES256, EdDSA, RS256) so other services can verify them Several services, or third parties, verify statelessly ES256 and Ed25519 are flagged; RSA-2048 is the legacy tier Algorithms, libraries, rotation
Issued by an identity provider and only verified by you Auth0, Clerk, Cognito, Entra ID, Firebase, Google, Okta, Supabase Mostly RSA-2048; Supabase recommends P-256 (ES256). Only the vendor can change the key Identity providers
Not JWTs: opaque session IDs or Starlette session cookies Server-rendered apps None (HMAC) This section

Signed JWTs are not encrypted, so their transport still matters.

A FastAPI service becomes exposed through what surrounds it:

  • inbound TLS at a proxy, load balancer or the ASGI server (Uvicorn, Hypercorn, Granian), including P-256 leaf certificates, and outbound TLS from httpx, aiohttp, boto3, asyncpg, psycopg, redis-py and pymongo: harvest-now-decrypt-later, so fix it now (hops);
  • asymmetric JWTs: changing ALGORITHM to ES256 or EdDSA (common when other services verify tokens statelessly), legacy python-jose, or validating third-party IdP tokens across JWKS rotations (algorithms, IdPs);
  • passkeys and Web Push (passkeys, Web Push);
  • app-level ECDH or X25519 encryption (stored ciphertexts).
Backgroundwhat FastAPI's own JWT tutorial does, and how it got there

The tutorial, “OAuth2 with Password (and hashing), Bearer with JWT tokens” (source at 0.165.1, source on master), does three things:

  • installs PyJWT (uv add pyjwt, noting that pyjwt[crypto] is needed for RSA/ECDSA);
  • sets ALGORITHM = "HS256", SECRET_KEY from openssl rand -hex 32 and ACCESS_TOKEN_EXPIRE_MINUTES = 30;
  • hashes passwords with pwdlib[argon2] and PasswordHash.recommended() (Argon2id).

Its library choices have moved over time (FastAPI release notes):

  • PR #1610 moved it from PyJWT to python-jose.
  • PR #11589 moved it back to PyJWT.
  • PR #13917 replaced passlib with pwdlib + Argon2.

A single-service FastAPI backend using HS256 (with a secret of at least 256 bits) and pwdlib Argon2id is unaffected at the application-auth layer.

VersionsFastAPI releases and maintainer statements since 1 Dec

Sources disagree. The Claude and AGY reports cite FastAPI 0.165.0 (18 Nov 2026) as the latest release, and the Claude report says there was no release after the advisory. The ASTRA report found 0.165.1, released 3 Dec 2026, whose release notes list a Swagger UI file-picker fix, not a cryptographic migration ASTRA. All three agree there is no advisory-specific change.

  • No statement from tiangolo (Sebastián Ramírez) or Kludex (Marcelo Trylesinski) has been found since 1 Dec 2026.
  • The only government-crypto-adjacent precedent is a 2022 Starlette bump for FIPS compatibility (FastAPI PR #4483).
  • The ASTRA report identified no advisory-specific FastAPI or PyCA patch in the release material it examined.
  • How FastAPI itself is published (no PEP 740 attestations since 0.128.0) is covered in the FastAPI package record and on the supply-chain page.

Each TLS hop around a FastAPI app has its own owner#

The ASTRA report’s first instruction is to “Start with the TLS terminator and the identity provider, not pip install -U fastapi cryptography.” A typical request has two independent protections: TLS establishes a secret for the connection, and the API verifies a token or other credential to decide who may use it. Moving one to post-quantum cryptography does not move the other. FastAPI’s own deployment guide describes proxy termination.

There are usually four separately owned handshakes. The edge (CDN, load balancer or ingress) faces clients and may open a second TLS or mTLS connection to an origin or mesh sidecar. Some services let clients reach Uvicorn directly. And the app makes its own outbound connections to the IdP’s JWKS, upstream APIs, KMS, databases and telemetry, which the ingress team cannot change by updating a listener.

Measure each one at its terminator. A redirect, HSTS or X-Forwarded-Proto: https is not handshake evidence, and verify=False is never a way to make a migration succeed. Which interpreters, servers and proxies negotiate X25519MLKEM768, and how to require or verify it, is on the TLS page. Granian cannot negotiate the hybrid at all, so put a capable proxy in front of it.

Tablethe ASTRA report's deployment hops, where to change each and what proves it
Deployment or credential Where to change it How to tell it worked
Browser/client → CDN, load balancer or ingress → HTTP Uvicorn The edge, not a route decorator or Starlette’s HTTPS redirect. The plaintext hop has no TLS group: document its trust boundary and restrict direct backend access. Edge connection log shows the selected group by client cohort. A redirect, HSTS, or X-Forwarded-Proto: https is not handshake evidence.
Edge → TLS/mTLS origin, mesh sidecar → service Configure and measure this second connection separately. For mTLS, migrate server and client identities, trust stores, and the workload-identity check. Confirm group and peer identity in both required directions; reject unintended trust paths. An authenticating proxy must not accept spoofed identity headers from untrusted clients.
Clients → Uvicorn directly Uvicorn 0.55.0 creates a stdlib SSLContext and supports a programmatic ssl_context_factory. Its ssl_ciphers calls set_ciphers(), not set_groups(). Test the actual container/interpreter and socket. Configure client-certificate verification explicitly if mTLS is intended.
App → IdP/JWKS, upstream APIs, KMS, databases or telemetry The outbound client or sidecar, and the peer. The ingress team cannot change this handshake by updating the listener. Measure actual egress by destination and build. Verify trust and names; never use verify=False to make a migration succeed.
Recipea strict hybrid-only canary for direct Uvicorn (ASTRA report)

On CPython 3.15 with a capable OpenSSL, pass the following as ssl_context_factory= to uvicorn.Config with your staging certificate and key and your existing verification settings. It deliberately rejects classical-only clients. It is not a general public-edge setting, an NSS profile, or a change to certificate authentication. The Claude report’s tested variant of the same hook, and its caveat about --workers and reload, are on the TLS page.

import ssl

def hybrid_only_canary(config, default_factory):
    ctx = default_factory()  # preserves the configured cert, CA, client-auth and ALPN settings
    ctx.minimum_version = ssl.TLSVersion.TLSv1_3
    ctx.set_groups("X25519MLKEM768")
    return ctx

An AWS ALB listener’s default policy depends on how it was created#

AWS ALB documentation lists different defaults for new listeners: console creation uses ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09, while CloudFormation, the CLI and other methods fall back to ELBSecurityPolicy-2016-08 when no policy is specified ASTRA. The PQ policy still allows classical clients. Inspect the actual listener and the tls_keyexchange field in its connection log; do not infer a fleet-wide change from the console default.

ALB selects its backend TLS policy separately and does not validate HTTPS target certificates, so do not describe the ALB-to-target hop as authenticated mTLS. By contrast, Cloudflare documents separate origin key-agreement and private origin-authentication controls, which shows what is possible where you control both ends. Per the Claude report, Cloudflare uses PQ automatically to origins that support it, and its “Post-quantum hybrid” compliance setting returns 525 when the origin lacks PQ.

Sources disagree. The Claude report, citing AWS’s PQ readiness page, lists ALB as opt-in: “Customers must update listener configuration”. The ASTRA report finds that console-created listeners default to the PQ policy and listeners created by other methods do not. Both lead to the same check: read each listener’s policy.

Stored public-key ciphertexts are the urgent part of app-level encryption#

The symmetric data layer is unaffected: Fernet, AES-GCM and KMS data keys. The exposure is in how keys move. The TLS channel to the KMS or secrets manager is a key-exchange problem, and a symmetric key is only as safe as the channel that delivered it: a Fernet key fetched from a secrets manager over X25519-only TLS inherits that exposure. Asymmetric key wrapping counts too, so keep RSA-OAEP wrapping at 3072 bits or more and migrate any ECDH-based wrapping.

Assume any stored public-key ciphertext is harvestable. That covers X25519 sealed boxes such as PyNaCl SealedBox, ECIES, JWE ECDH-ES and HPKE-DHKEM ciphertexts that are stored or have crossed an untrusted network. Re-encrypt them under symmetric keys or an ML-KEM hybrid. Ciphertexts an adversary has already captured cannot be protected retroactively, so start with data that crossed networks.

For an encrypted archive, ask what wrapped its data key; changing TLS does not change an old envelope. A migration may need a versioned envelope, new recipients, rewrapping or re-encryption, and a tested recovery path. Use a reviewed protocol implementation, such as PyCA’s HPKE suites, not a hand-built KEM/KDF/AEAD combiner; the exact profile, encoding and peer support still matter. Recipes are on the cryptography page.

JOSE has no released PQ encryption: joserfc lists JWE ECDH-ES (P-256/X25519) as “Recommended”, and PQ HPKE for JWE (draft-ietf-jose-hpke-encrypt) is still a draft. For direct AWS KMS calls, CloudTrail tlsDetails.keyExchange shows the exchange used on that call, not how a stored data key was wrapped (infra page).

HS256 is fine for a single service; ES256 and EdDSA are the exposed choices#

JWA algorithm names do not all mean what they suggest (JWA, RFC 7518):

alg What it uses Standing under the 256-bit reading
HS256 HMAC with SHA-256, not ECC. Every holder of the verification secret can mint tokens Not affected
ES256 ECDSA on P-256 Flagged
EdDSA Ed25519 or another Edwards curve: inspect the JWK crv Flagged if Ed25519
RS256, PS256 RSA with SHA-256; the 256 is not the modulus length RSA-2048 is the “legacy” tier; RSA-3072+ is an interim bridge
ES384 ECDSA on P-384 Interim bridge, not PQ
ML-DSA-44/65/87 RFC 9964, AKP keys Post-quantum target

HS256 remains fine for one service that both issues and verifies its tokens, provided SECRET_KEY has at least 256 bits of entropy (32 random bytes) and is rotated if exposed. A DEV write-up says “HMAC is fine… not on the urgent list”. No authoritative source states explicitly that HS256 or HMAC is unaffected; the conclusion follows from scope, since symmetric primitives are not on the advisory’s list. For long-term CNSA 2.0 alignment the AGY report suggests HS384 or HS512, as non-urgent work.

Asymmetric JWTs are needed only when verifiers must not hold the signing secret. Then use ES384, or RS256/PS256 with an RSA-3072+ key, today, and ML-DSA once your library supports it. That is a time-limited classical bridge, not PQ authentication. Do not replace an external issuer’s public-key verification with a shared secret as a shortcut.

ES256 exposure does not depend on publishing the key. ECDSA public keys can be recovered from a signature plus its message, so an attacker able to break P-256 needs only one captured ES256 token, even if the JWKS is private. This is the Claude report’s researchers’ inference, not a published attack.

Two verifier-side habits matter during any migration. Accepting a token’s alg header across RS256 and ES256 lets an attacker pick the weaker family (algorithm confusion), so pin algorithms per issuer. And PyJWT only warns below 2048-bit RSA (_MIN_KEY_SIZE = 2048, InsecureKeyLengthWarning, unless enforce_minimum_key_length is set) and has no 3072 floor, so enforce key size yourself.

Recipethe classical stopgap in PyJWT 2.15.1 (illustrative sketch, Claude report)
import jwt  # PyJWT 2.15.1 with the [crypto] extra
from cryptography.hazmat.primitives.serialization import load_pem_private_key

key = load_pem_private_key(pem_bytes, password=None)
assert key.key_size >= 3072          # PyJWT only warns below 2048; enforce 3072 yourself
token = jwt.encode(claims, key, algorithm="PS256")          # or ES384 with an ec.SECP384R1() key
jwt.decode(token, public_key, algorithms=["PS256"], audience="my-api")  # pin the alg per issuer

Only jwcrypto has a released ML-DSA JWT implementation#

RFC 9964 (May 2026, Standards Track; RFC info page) defines JWS ML-DSA-44, ML-DSA-65 and ML-DSA-87 and the "kty": "AKP" key type. Among Python JOSE libraries, only jwcrypto registers them in a release (since 1.5.9, with a cryptography ≥48 backend). PyJWT 2.15.1, joserfc 1.8.0 and Authlib 1.9.11’s legacy JOSE module do not register them as built-in JWS algorithms.

In an isolated environment with cryptography 51.0.0, the ASTRA researchers signed and verified a synthetic compact JWS with a public AKP key for each of the three parameter sets using jwcrypto 1.6.3; PyJWT’s default algorithm registry in the same environment contained none ASTRA. That was a same-library round trip, not a cross-vendor interoperability or OIDC certification test.

Library (30-day downloads) Classical stopgap ML-DSA (RFC 9964) Note
PyJWT 2.15.1 (763M) ES384, ES512, RS/PS256–512; enforce RSA size yourself PR #1256 open The tutorial’s library
joserfc 1.8.0 (154M) Yes, but “Optional”: pass algorithms=[...] PR #129 open Defaults allow HS256, RS256, ES256
Authlib 1.9.11 (161M) Via joserfc PR #1086 open authlib.jose is deprecated
jwcrypto 1.6.3 (19M) Yes released since 1.5.9 Least ergonomic
python-jose 3.5.0 (31M) ES384 and RS only; no PS256 none; stale Leave it
josepy 2.3.0 (2.9M) ES384, RS/PS none Used by certbot

A FastAPI service that needs PQ JWT signatures now has three options: jwcrypto; a pinned build of PyJWT PR #1256; or a custom signer calling cryptography ≥48 mldsa directly. Demand is visible in Python projects: Apache Airflow #78000, opened 3 Dec 2026, asks for ML-DSA JWT signing and notes it is blocked on PyJWT. Sending the tokens is a separate problem (sizes), and the code is in the JWKS recipe.

PyJWT PR #1256, opened 20 Nov 2026, adds ML-DSA-44/65/87 and AKP JWKs and needs cryptography ≥48. It drew community comments on 3 Dec 2026 but no maintainer comment. The equivalent PRs are joserfc #129 and Authlib #1086 (an OIDC ML-DSA PR opened 1 Dec 2026).

Sources disagree. The AGY report calls the PyJWT, joserfc and Authlib ML-DSA PRs “imminent”, says #1256 and #129 were updated on 3 Dec 2026, and suggests watching PyJWT 2.16.0. The OpenID Foundation’s October 2026 table lists PyJWT and Authlib as “No Plans Yet”. An Auth0 Community post claims PyJWT “has begun incorporating” ML-DSA; the Claude report treats that as false until a release, since the PR is unmerged.

Leave python-jose. It has had no release since May 2025, pins pycryptodome<4 (which blocks pycryptodome’s PQ code), depends on the pure-Python ecdsa package, and has no PS256, EdDSA or ML-DSA. The AGY report also lists an unpatched CVE-2026-85394 (CVSS 9.1–9.3, a DER key to HMAC confusion) AGY. Replace it with PyJWT ≥2.15.1, joserfc ≥1.8.0 (if you need JWE) or jwcrypto ≥1.6.3 (for ML-DSA today).

Unverified. CVE-2026-85394 appears only in the AGY report. The Claude report describes python-jose as stale without mentioning a CVE.

Tablefull JOSE library comparison, including EdDSA, mixed JWKS and dependency floors
Library EdDSA Mixed JWKS with AKP Declared cryptography requirement PRs, CVEs and notes
PyJWT 2.15.1 (28 Sep 2026) Yes (also ES256K) AGY: yes, PyJWKSet skips unknown kty. Claude: not verified >=3.4.0 via the crypto extra PR #1256. RSA floor warns only. No default algorithm
joserfc 1.8.0 (3 Nov 2026) Ed25519/Ed448 optional; EdDSA deprecated (RFC 9864) Yes (PR #103) >=45.0.1 PR #129. Requires Python 3.11+. JWE ECDH-ES “Recommended”
Authlib 1.9.11 (2 Dec 2026) Via joserfc Via joserfc >=45.0.1 PR #1086. Uses joserfc>=1.6.8. authlib.jose deprecated: “please use joserfc instead” (removal in 2.0.0)
jwcrypto 1.6.3 (2 Dec 2026) Ed25519/Ed448 (1.5.7) Yes, skips unknown kty (#388) >=39.0.0; ML-DSA needs >=48 ML-DSA via PR #384 in 1.5.9; optional since 1.6.2. 1.6.3 fixes DoS CVE-2026-142105
python-jose 3.5.0 (28 May 2025) No AGY: no, brittle Optional; hard deps ecdsa and rsa; pycryptodome<4.0.0 via extra CVE-2026-85394 (AGY only). Timing-unsafe pure-Python ecdsa default
josepy 2.3.0 No Not reported Not reported ACME library used by certbot (PyPI josepy)

Sources: PyJWT 2.15.1 algorithms.py, joserfc 1.8.0 jwa.py, joserfc algorithms guide, Authlib 1.9.11 jose/__init__.py, JWCrypto 1.6.3 jwa.py. Per-library detail is in each package record.

BackgroundML-DSA JOSE outside Python, and the surrounding standards
  • The OpenID Foundation’s October 2026 table lists ML-DSA support in panva/jose, Microsoft IdentityModel, web-token/jwt-framework, lestrrat-go/jwt, jwt-simple and jose-rs. It lists PyJWT and Authlib as “No Plans Yet”.
  • A developer write-up adds that panva/jose (since v6.1.0), go-jose v4.1.8 and Microsoft.IdentityModel 8.19.0 have released support, and lists PyJWT, jjwt, golang-jwt and Nimbus as not yet released.
  • RFC 9864 (Oct 2025, “Fully-Specified Algorithms for JOSE and COSE”) deprecated polymorphic EdDSA in favor of explicit Ed25519/Ed448.
  • RFC 9964 (May 2026) is the published ML-DSA JOSE/COSE RFC. SLH-DSA for JOSE/COSE is in IETF Last Call; composite signatures and PQ HPKE (draft-ietf-jose-hpke-encrypt) are working-group drafts.

Identity providers sign with RSA-2048, except where P-256 is required#

Live JWKS checks by the Claude researchers on 3 Dec 2026 show the major IdPs all signing with RSA-2048 RS256; Microsoft’s keys carry no alg field. That puts them in Valsorda’s “legacy” tier, below the NSA’s 3072-bit preference, but not in the “256-bit curves” bucket. The AGY report adds Okta and AWS Cognito to the RS256 defaults (historically RSA-2048) and expects rotations to RSA-3072, RS384, ES384 or ML-DSA-65, so check the modulus length in each live JWKS.

Provider JWKS result (3 Dec 2026)
Google OIDC 2 keys, RSA, RS256, 2048-bit (JWKS)
Microsoft Entra ID (common v2.0) 7 keys, RSA, 2048-bit, no alg (JWKS)
Apple (Sign in with Apple id_token) 3 keys, RSA, RS256, 2048-bit (JWKS)
Firebase Auth 2 keys, RSA, RS256, 2048-bit (JWKS)
Auth0 (samples tenant) 2 keys, RSA, RS256, 2048-bit (JWKS)
Clerk (Clerk’s own instance) 1 key, RSA, RS256, 2048-bit (JWKS)

There are two P-256 exceptions. Supabase recommends ES256 (“We recommend using the P-256 elliptic curve instead”), with the example supabase gen signing-key --algorithm ES256; its EdDSA option is “Coming soon”. The AGY report describes ES256 as Supabase Auth’s default. Sign in with Apple requires apps to sign their client-secret JWT with ES256 using a .p8 P-256 key, which the app cannot change.

The highest-exposure app-auth setups, in order:

  1. Supabase projects using ES256 asymmetric keys.
  2. Self-issued ES256 or EdDSA service tokens: internal JWTs, API gateways, DPoP proofs (commonly ES256), and private_key_jwt client authentication with EC keys.
  3. Sign in with Apple client secrets: guard and rotate the .p8 key.

No large IdP has announced ML-DSA token signing, and no IdP statement since 1 Dec 2026 was found. Auth0 recommends RS256 and offers HS256 and PS256. Keycloak has an open ML-DSA issue for OAuth/OIDC, and Okta’s roadmap “starts with hybrid key exchange” (DEV, jamilxt). Cloudflare plans PQ JWTs in Q2 2027.

Editorial note. Checked for this guide; not from the three reports. Amazon Cognito signs user-pool tokens with its own RSA-2048 keys (RS256), not with keys from your KMS (Cognito). API Gateway HTTP API JWT authorizers support only RSA-based algorithms (API Gateway), so behind one, RSA is the only stopgap: ES384 is ruled out as well as ML-DSA. Other AWS services that cannot use ML-DSA keys yet are on the boto3 page.

JWKS parsing must tolerate AKP keys before IdPs publish them#

The OpenID Foundation warns that some libraries throw “an error and fails the entire JWKS” when an unknown kty such as AKP appears. When IdPs start publishing ML-DSA keys beside RSA keys (a mixed JWKS with kty: "AKP" entries), such a verifier breaks login. Test your verifier with a synthetic AKP entry.

Sources disagree. The AGY report says PyJWT’s PyJWKSet skips unknown kty values, as do jwcrypto (#388) and joserfc (PR #103), and that python-jose is brittle. The Claude report did not verify whether PyJWT 2.15.1’s PyJWKClient/PyJWKSet skips or raises, and lists it as an open question (unknowns).

Pin algorithms per issuer, and never trust the header alg: algorithms=["RS256"] for the RSA IdPs above. The opposite mistake also breaks things. The AGY report warns that FastAPI apps with jwt.decode(token, key, algorithms=["ES256"]) will have an auth outage the moment Supabase or another IdP rotates to ES384, RS384, PS384 or ML-DSA-65 AGY.

When the issuer is external, ask the vendor and contain the dependency#

Ask the IdP which access-token profile, algorithms, JWKS keys, KMS/HSM and verifier SDKs it actually supports. The OIDC discovery field id_token_signing_alg_values_supported describes ID tokens, not every API access token. If the vendor is not ready, keep strict current verification, limit token lifetime and scope, and record the vendor dependency. Locally re-signing an IdP token does not strengthen its original identity proof.

Rotate your own issuer through JWKS with algorithms bound to the issuer#

For tokens you issue, the sequence is: HS256 single-service tokens need no change; ES256 or EdDSA move to ES384 or PS256/RS256 with a new RSA-3072+ key (with joserfc, pass algorithms=[...] explicitly); then to ML-DSA-65 (ML-DSA-87 for CNSA 2.0) via jwcrypto today or PyJWT once #1256 merges. Also check private_key_jwt client-assertion keys, DPoP keys, signed URLs and webhook signatures. The full checklist is in the playbook.

Deploy verifiers and publish distinct new keys first. Bind allowed algorithms and key sources to the trusted issuer, not to a token header, and check signature, issuer, audience, expiry, token type and authorization. Rotate with old and new keys side by side under a new kid and shorter TTLs; canary new issuance; test JWKS caching, rollover and old-client rejection.

Retire old keys and old acceptance paths only after the bounded token lifetime, cache and clock-skew windows have passed. Accepting either signature during the transition is compatibility, not a requirement for both (JWT best current practice, JWT access-token profile).

Recipezero-downtime JWKS verifier (PyJWT) and ML-DSA JWTs today (jwcrypto), from the AGY report

The first half pins an asymmetric allowlist for a rotating IdP; the second signs and verifies an RFC 9964 ML-DSA-65 JWT with jwcrypto ≥1.6.3 and cryptography ≥48.0. The comment on cache_jwk_set reflects the AGY report’s claim, which the Claude report did not verify (see above). An ML-DSA-65 token of about 4.8 KB belongs in an Authorization: Bearer header, not a cookie (sizes).

# 1. Interim Zero-Downtime FastAPI JWKS Verifier (PyJWT >= 2.15.1)
import jwt
from jwt import PyJWKClient

jwks_client = PyJWKClient(
    "https://idp.example.com/.well-known/jwks.json",
    cache_jwk_set=True,  # Skips unknown kty (e.g. future AKP keys) without crashing
    lifespan=300,
)
# Strictly asymmetric allowlist (NEVER include HS* alongside asymmetric keys!)
# Remove "ES256" as soon as upstream IdP completes rollover.
ALLOWED_ASYMMETRIC_ALGS = ["ES384", "RS384", "PS384", "RS256"]

def verify_bearer_token(token: str) -> dict:
    signing_key = jwks_client.get_signing_key_from_jwt(token)
    return jwt.decode(
        token,
        signing_key.key,
        algorithms=ALLOWED_ASYMMETRIC_ALGS,
        audience="my-fastapi-api",
        issuer="https://idp.example.com/",
    )

# 2. Production RFC 9964 ML-DSA JWT Signing/Verification TODAY (jwcrypto >= 1.6.3 + cryptography >= 48.0)
from jwcrypto import jwk, jwt as jwcrypto_jwt

key = jwk.JWK.generate(kty="AKP", alg="ML-DSA-65")  # 32B seed priv, 1952B pub
tok = jwcrypto_jwt.JWT(
    header={"alg": "ML-DSA-65", "kid": key.thumbprint()},
    claims={"sub": "user-123", "iss": "https://api.example.com", "aud": "my-service"},
)
tok.make_signed_token(key)
serialized = tok.serialize()  # ~4.8 KB: send in Authorization: Bearer, NOT Set-Cookie!

pub = jwk.JWK.from_json(key.export_public())
verified = jwcrypto_jwt.JWT(jwt=serialized, key=pub, algs=["ML-DSA-65"])

ML-DSA tokens do not fit in cookies and strain default header buffers#

ML-DSA signatures are 38–72 times larger than ES256 or Ed25519 ones. ML-DSA-44 public keys are 1,312 bytes and signatures 2,420 bytes, against 256 bytes for an RS256 signature at 2048 bits (OpenID Foundation). A 192-character ES256 token grows to 3,339 characters with ML-DSA-44, and an ML-DSA-65 token “does not fit” a 4096-byte cookie “even before you add real claims” (DEV, jamilxt).

The ASTRA researchers measured the base64url signature segment alone at 3,227 / 4,412 / 6,170 characters for ML-DSA-44/65/87 ASTRA, matching the AGY report’s computed sizes. Check cookie, header, gateway and proxy limits with your real claim sizes.

Unlike handshake bytes, a token’s size is paid on every request. An ML-DSA-65 JWT carries 4,326 B more than an ES256 one, about 3.7 TB a day of extra header data at 10,000 requests per second ASTRA. Connection reuse does not reduce it, and HTTP/2 header compression does not either (wire cost).

For browser sessions, the PQ-era answer is an opaque or HMAC-signed server-side session, not an ML-DSA JWT in a cookie. Starlette, Django and Flask already provide one. The AGY report calls this the Backend-for-Frontend (BFF) pattern: an opaque session cookie (Starlette SessionMiddleware plus a Redis or Postgres session ID), with ML-DSA JWTs kept strictly in Authorization: Bearer headers for API and machine-to-machine traffic.

The limits that break first, per the AGY report AGY:

Layer Default limit What happens with ML-DSA tokens Fix
Browsers (RFC 6265) 4,096 B per cookie Set-Cookie silently dropped for ML-DSA-65/87 JWTs; breaks fastapi-users CookieTransport and cookie-stored OIDC tokens BFF opaque session cookie
nginx large_client_header_buffers 4 8k (8 KB per header line) 400 Bad Request (or Cloudflare HTTP 520) when an ML-DSA-87 JWT with rich RBAC claims exceeds 8 KB large_client_header_buffers 4 32k;
Uvicorn 0.55.0 and Hypercorn 0.18.0 on h11 16 KB total incomplete event size Header blocks over the limit fail --h11-max-incomplete-event-size 65536
Uvicorn on httptools (llhttp) Caps at about 80 KiB Not reported Not CLI-tunable in Uvicorn
AWS ALB 16 KB single header, 64 KB total request (hard limits) Safe for one ML-DSA-87 JWT Watch multi-token stacks such as x-amzn-oidc-data plus Authorization
JWKS documents About 2 KB today A 5-key rotated ML-DSA-65/87 JWKS grows to about 15–20 KB Cache: PyJWKClient(..., cache_jwk_set=True) in PyJWT ≥2.15.0 caches parsed PyJWKSet objects
TableJWT sizes by algorithm (AGY report, 48 B JWS header and 250 B claims assumed)
Algorithm Role Raw sig Base64url sig Typical JWT Authorization: Bearer ... Set-Cookie (with attrs) Raw public key Fits a 4,096 B cookie
HS256 (HMAC) Unaffected 32 B 43 B 443 B 465 B 508 B n/a Yes
ES256 / Ed25519 Migrate off 64 B 86 B 486 B 508 B 551 B 64 / 32 B Yes
ES384 (P-384) Stopgap 96 B 128 B 528 B 550 B 593 B 96 B Yes
RS384 / PS384 (RSA-3072) Stopgap 384 B 512 B 912 B 934 B 977 B 384 B Yes
ML-DSA-44 (RFC 9964) PQ 2,420 B 3,227 B 3,627 B 3,649 B 3,692 B 1,312 B Fragile: breaks if claims exceed about 550 B
ML-DSA-65 (RFC 9964) PQ 3,309 B 4,412 B 4,812 B 4,834 B 4,877 B 1,952 B No: the signature alone exceeds 4,096 B
ML-DSA-87 (RFC 9964) PQ 4,627 B 6,170 B 6,570 B 6,592 B 6,635 B 2,592 B No: the signature alone exceeds 4,096 B

Columns sized for ECC keys reject or truncate ML-DSA values#

ML-DSA-65 signatures are about 52 times the size of Ed25519 ones (3,309 B against 64 B), and public keys grow from 32 B to 1,952 B. The ASTRA report warns that SQLAlchemy, Alembic and Django ORM columns declared as VARCHAR(255), VARCHAR(512) or VARCHAR(1024) for public keys, API tokens, WebAuthn COSE keys or audit signatures will fail or silently truncate ASTRA.

Stored value Ed25519 / P-256 ML-DSA-65
Public key, raw 32 B / 65 B 1,952 B
Public key, base64 44 / 88 characters 2,604 characters
Public key, PEM 113 / 178 characters 2,726 characters
WebAuthn COSE public key about 42 B / 77 B about 1,960 B
Signature, raw 64 B / 64 B (JWS) or about 72 B (DER) 3,309 B
Signature, base64url 86 characters 4,412 characters
JWT with 250 B of claims 486 B (ES256) 4,812 B

Widen the columns before the first ML-DSA key, token or signature is written, and test against the database you run in production. Move bounded string columns that hold keys, signatures or tokens to Text or LargeBinary in SQLAlchemy, or TextField or BinaryField in Django, and store raw bytes where you can: base64 adds a third and PEM more.

Editorial note. Checked for this guide; not from the three reports. Whether an over-length write fails or truncates depends on the database. PostgreSQL raises an error (character types). MySQL truncates with only a warning when strict mode is off and errors when it is on, as it is by default (strict mode). SQLite does not enforce VARCHAR lengths (SQLite FAQ): a 2,604-character key went into a VARCHAR(255) column intact, so a SQLite test suite passes where PostgreSQL fails.

Recipefind and widen the columns (this guide's steps)

List bounded columns whose names suggest keys, signatures or tokens from your SQLAlchemy metadata (tested with SQLAlchemy 2):

HINTS = ("key", "pub", "sig", "token", "jwt", "credential", "cose")

for table in Base.metadata.sorted_tables:  # your declarative Base
    for col in table.columns:
        length = getattr(col.type, "length", None)
        if length and any(h in col.name.lower() for h in HINTS):
            print(f"{table.name}.{col.name}: {type(col.type).__name__}({length})")

Widen one with Alembic:

def upgrade() -> None:
    op.alter_column(
        "webauthn_credential", "public_key",
        existing_type=sa.String(255), type_=sa.Text(),
    )

In Django, change models.CharField(max_length=255) to models.TextField() (or models.BinaryField() for raw bytes) and run makemigrations.

Do not index the key or signature itself; index a SHA-256 fingerprint of it. PostgreSQL rejects B-tree index entries over about 2,704 B (index row size), which a 2,726-character PEM key exceeds. InnoDB caps index keys at 3,072 B (InnoDB limits) and needs a prefix length to index TEXT or BLOB columns.

Auth frameworks default to HS256, and several hardcode the asymmetric algorithm#

The common auth add-ons default to HMAC, so their default deployments are not exposed. The work starts when you configure asymmetric keys: several accept only one algorithm at a time or hardcode RS256, which blocks a zero-downtime rotation. These details come from the AGY report AGY; per-package detail is in the auth frameworks record.

Package Default Asymmetric options Catch during migration
fastapi-users 15.0.5 HS256 (PyJWT) Asymmetric if a public key is passed; same as PyJWT JWTStrategy.read_token passes algorithms=[self.algorithm]; subclass it to accept a list during rotation. ML-DSA-65/87 cannot go in CookieTransport
djangorestframework-simplejwt 5.5.1 HS256 ES384, RS384, PS384 None reported
Flask-JWT-Extended 4.7.4 HS256 ES384, RS384, PS384 JWT_DECODE_ALGORITHMS list already allows zero-downtime rollover
django-oauth-toolkit 3.4.1 Not reported RS256 only, though it depends on jwcrypto>=1.5.0, which has ML-DSA Application.ALGORITHM_TYPES hardcoded to RS256 and HS256 (models.py:L185-192). Interim: rotate OIDC_RSA_PRIVATE_KEY to RSA-3072
django-allauth 65.23.0 OIDC IdP mode hardcodes RS256 Socialaccount OIDC client reads jwt.algorithms.get_default_algorithms() Use RSA-3072 keys in IdP mode; the client adapts to ES384/RS384 and future PyJWT ML-DSA on its own

Passkeys need a re-enrollment program, not a switch-off#

Nearly all deployed passkeys sign with ES256 (-7, P-256), and some with EdDSA (-8, Ed25519): Apple’s Secure Enclave and iCloud Keychain, Android Keystore and Google Password Manager, Windows Hello and existing YubiKey 5s. An ML-DSA-44 assertion signature is 2,420 bytes, against 64 bytes for P-256 (Corbado). The relying party cannot re-key existing credentials; users must register new ones.

The Python relying-party libraries are ready on the verification side. py_webauthn 3.0.0, “The PQC release” (29 Jun 2026), verifies ML-DSA-44/65/87, but its default supported_pub_key_algs is still [EDDSA (-8), ECDSA_SHA_256 (-7), RSASSA_PKCS1_v1_5_SHA_256 (-257)]. python-fido2 2.2.1 lists and verifies ML-DSA COSE algorithms only when its PyCA backend supports them, and still supports ES256. Backend verification support cannot upgrade an existing authenticator’s key, browser or hardware.

What a FastAPI relying party should do:

  1. Pass supported_pub_key_algs explicitly to py_webauthn: ML-DSA-65 (-49) and ML-DSA-44 (-48) first, then RS256 (-257), then ES256 (-7) and EdDSA (-8) as compatibility fallbacks. Do not keep the library default, which prefers EdDSA.
  2. Store each credential’s COSE algorithm, and keep its public key in a column wide enough for an ML-DSA-65 COSE key of about 1,960 B (storage).
  3. Prompt users to add a PQ passkey when their authenticator supports one, and test enrollment, recovery and re-enrollment with capable devices.
  4. Do not require ML-DSA yet; that would lock out almost every platform authenticator.
  5. Treat the stored credential public-key table as sensitive and never expose it in public APIs. If P-256 private keys become recoverable from public keys, a database leak would enable assertion forgery. Tighten session binding and anomaly detection.

Passkeys still beat passwords. Forging an assertion is an online, per-key attack, so this is a months-long re-enrollment program, not an emergency; do not disable phishing-resistant MFA on the strength of this alert. Library-specific traps (py_webauthn lacks ES384, a docs typo, fido2’s ML-DSA attestation chains) are in the py_webauthn and python-fido2 records.

Evidenceauthenticator support for ML-DSA passkeys as of 3 Dec 2026
  • 1Password offers ML-DSA passkeys, but creating them is not supported on iOS or through native macOS autofill.
  • Yubico has a PQC beta for developers from 3 Nov 2026. Per Dark Reading, the beta keys are not firmware-upgradable and FIPS validation is about a year away.
  • Chrome DevTools offers virtual ML-DSA authenticators (AGY report).
  • Keycloak’s ML-DSA WebAuthn preview sits behind PQC_ML_DSA_WEBAUTHN in the 27.0 milestone. Its explicit non-goals are making ML-DSA the default and migrating existing credentials (keycloak#50084).
  • No confirmed Apple, Google or Microsoft platform ML-DSA passkeys exist. FIDO, Apple, Google, Microsoft and Yubico have said nothing since 1 Dec 2026.
  • The AGY report’s medium-term step: roll out ML-DSA passkeys via python-fido2 ≥2.2.1 or py_webauthn ≥3.0.1 as Apple, Google and Microsoft OS passkey providers add native ML-DSA support.

Web Push is hard-wired to P-256 and has no successor#

Web Push uses P-256 in two places. VAPID (RFC 8292) signs with ES256: py-vapid 1.9.6 generates ec.SECP256R1() keys and signs with ECDSA(SHA256). RFC 8291 payload encryption uses ephemeral P-256 ECDH plus a 16-byte auth secret, then aes128gcm, which pywebpush 2.5.0 implements (py_vapid, pywebpush).

Forging VAPID is low-impact: without the subscription’s auth secret, the browser will not display attacker payloads. The real exposure is payload confidentiality. Push services (FCM, Mozilla autopush, Apple) relay the ciphertext, so anyone recording it could decrypt it later if P-256 ECDH falls.

No IETF replacement draft or browser plan was found. Until one exists, send “tickle” notifications that carry only an ID, and fetch the content over PQ-hybrid TLS.

Public and private certificates for an API follow different paths#

For private PKI and internal mTLS, pilot ML-DSA issuance and verification end to end, distribute roots before changing leaves, and test expiry, revocation, recovery and eventual rejection of old chains. A new leaf alone is insufficient if a classical trusted issuer can still assert the same identity. Hybrid key exchange does not wait for any of this: it works with existing RSA or ECDSA certificates (TLS page).

For public HTTPS, keep normal browser and OS trust and work with your CA or ACME client. RFC 9881 X.509 encoding does not imply public WebPKI acceptance; Let’s Encrypt’s documented account and certificate key choices are RSA or P-256/P-384 ECDSA. Inspect ACME account keys too (certbot, infra page). Do not globally remove public roots or deploy an untrusted ML-DSA public-site certificate to meet an internal deadline.

Django and Flask sign with HMAC and need no change#

Flask 3.1.3 sessions use itsdangerous HMAC-SHA1, like Starlette. Django 6.1.4 (2 Dec 2026, a security release unrelated to the advisory) signs with Signer, HMAC-SHA256 by default, and the AGY report says its sessions and CSRF tokens use HMAC-SHA256 too (django signing.py). base64_hmac()’s default changes from sha1 to sha256 in “Django 2028”. The CSRF assessment is based on design knowledge, not re-verified.

Django signing uses a keyed MAC, and password hashing and AEAD are separate from public-key signatures and key exchange. Keep independent, high-entropy secrets and ordinary rotation and patching. Starlette has no built-in key fallback for rotation, so plan that yourself.

Investigate the channels that carry cookies, passwords and keys rather than resetting every user password. Put a PQ-capable reverse proxy in front of every FastAPI, Django or Flask app (hops). The Claude report’s conclusion is that HMAC sessions, HS256 JWTs and hash-pinned lockfiles are the layers that survive a hypothetical curve break, and should be treated as security features rather than legacy.

Password hashes need no rehash#

Password hashing uses no public-key cryptography, so no rehash is needed: Argon2id, bcrypt, scrypt and PBKDF2 are all outside the advisory. The AGY report lists them among the things not to touch during emergency triage, alongside hashlib, hmac and secrets. CNSA 2.0 prefers 256-bit symmetric strength long-term against Grover’s algorithm, which is a separate and slower concern.

The password-hashing record covers argon2-cffi 25.1.0, pwdlib 0.4.2, bcrypt 5.1.0 and passlib 1.9.6, revived on 3 Dec 2026 under notypecheck/passlib AGY. FastAPI’s tutorial uses pwdlib[argon2] with PasswordHash.recommended() (PR #13917 replaced passlib). Django’s default hasher is PBKDF2, with Argon2, bcrypt and scrypt also available.

The layer-by-layer plan for a FastAPI service is in the playbook#

For a typical FastAPI service the order is: TLS at the edge and on every inner and outbound hop now; re-encrypt stored public-key ciphertexts and stop sending sensitive push payloads now; inventory asymmetric JWTs and pin algorithms= now, then move to a classical stopgap and to ML-DSA as libraries ship. Passkeys are a months-long program. FastAPI core, SessionMiddleware, HS256 and password hashes need nothing beyond key-rotation hygiene.

The per-layer table (do now, prepare, monitor) and the full checklist are in the playbook. Watch items for this area are PyJWT#1256, joserfc#129 and authlib#1086, IdP AKP keys and ML-DSA token signing (OIDF), platform ML-DSA passkeys (FIDO) and a Web Push successor (IETF); see trackers and unknowns.

The Claude report’s summary of the gap: Python’s authentication layer has almost no PQ path, and much of the ecosystem’s trust is concentrated on a single curve. The default keys of py_webauthn’s registration options and pywebpush converge on P-256 or Ed25519. The same conclusion names PyJWT’s ML-DSA PR, with the PSF’s planned PQC PEP and Sigstore’s mid-2027 PQ root, as work the whole ecosystem now depends on.

Sources cited on this page 67
  1. PyPI fastapi 0.165.0 pypi.org
  2. FastAPI 0.165.1 metadata pypi.org
  3. sessions.py github.com
  4. itsdangerous signer.py github.com
  5. FastAPI’s OAuth2PasswordBearer github.com
  6. official tutorial fastapi.tiangolo.com
  7. source at 0.165.1 github.com
  8. source on master github.com
  9. FastAPI release notes fastapi.tiangolo.com
  10. release notes github.com
  11. FastAPI PR #4483 github.com
  12. deployment guide github.com
  13. Uvicorn 0.55.0 github.com
  14. AWS ALB documentation docs.aws.amazon.com
  15. does not validate HTTPS target certificates docs.aws.amazon.com
  16. Cloudflare documents separate origin key-agreement and private origin-authentication controls developers.cloudflare.com
  17. AWS’s PQ readiness page aws.amazon.com
  18. PyCA’s HPKE suites cryptography.io
  19. JWA, RFC 7518 rfc-editor.org
  20. DEV write-up dev.to
  21. RFC 9964 rfc-editor.org
  22. RFC info page rfc-editor.org
  23. Apache Airflow #78000 github.com
  24. PyJWT PR #1256 github.com
  25. joserfc #129 github.com
  26. Authlib #1086 github.com
  27. Auth0 Community post community.auth0.com
  28. PR #384 github.com
  29. PyPI josepy pypi.org
  30. PyJWT 2.15.1 algorithms.py github.com
  31. joserfc 1.8.0 jwa.py github.com
  32. joserfc algorithms guide jose.authlib.org
  33. Authlib 1.9.11 jose/__init__.py github.com
  34. JWCrypto 1.6.3 jwa.py github.com
  35. OpenID Foundation’s October 2026 table openid.net
  36. RFC 9864 rfc-editor.org
  37. JWKS googleapis.com
  38. JWKS login.microsoftonline.com
  39. JWKS appleid.apple.com
  40. JWKS googleapis.com
  41. JWKS samples.auth0.com
  42. JWKS clerk.clerk.com
  43. Supabase supabase.com
  44. Sign in with Apple developer.apple.com
  45. Auth0 auth0.com
  46. Cloudflare blog.cloudflare.com
  47. Cognito docs.aws.amazon.com
  48. API Gateway docs.aws.amazon.com
  49. ID tokens openid.net
  50. JWT best current practice rfc-editor.org
  51. JWT access-token profile rfc-editor.org
  52. character types postgresql.org
  53. strict mode dev.mysql.com
  54. SQLite FAQ sqlite.org
  55. index row size supabase.com
  56. InnoDB limits dev.mysql.com
  57. Corbado corbado.com
  58. 1Password 1password.com
  59. Yubico yubico.com
  60. Dark Reading darkreading.com
  61. keycloak#50084 github.com
  62. py_vapid github.com
  63. pywebpush github.com
  64. RFC 9881 rfc-editor.org
  65. Let’s Encrypt’s documented account and certificate key choices letsencrypt.org
  66. django signing.py github.com
  67. Django signing github.com

All sources across the guide