# Migrate: tokens (JWT, JOSE, COSE)

**What is at stake.** Token signatures (RS256, ES256, EdDSA) are not "harvest now, decrypt later" risks: a recorded token does not become readable because of a future break. The risk is forgery from the day of a break, for as long as a signing key is trusted. So tokens come in wave 3, and the work now is to make the later switch a configuration change.

Encrypted tokens (JWE with `RSA-OAEP`, `ECDH-ES`) are different: their content can be recorded now. Treat those like `migrate/code.md` (move the secret out of the token, or plan re-encryption).

## Do now

1. **Algorithm allow-list from configuration.** The verifier accepts only the algorithms listed in config and never trusts the token's own `alg` header to choose. No `none`. No `HS256` on a verifier that also holds RSA public keys.
2. **Short lifetimes.** Access tokens in minutes, not days. Long-lived refresh tokens are rotated.
3. **Key rotation by `kid`.** Configure a trusted issuer and its JWKS endpoint. Use the token’s `kid` only to select a key in that issuer’s set. A new key and algorithm can coexist with the old ones during rotation.
4. **Know who signs.** If an identity provider signs your tokens, the switch is the provider's. Put it on the vendor list: "Which algorithm signs our tokens? When will ML-DSA be available?"

## The standard identifiers

RFC 9964 (May 2026, Standards Track) defines ML-DSA for JOSE and COSE (checked 2026-12-03):

| | ML-DSA-44 | ML-DSA-65 | ML-DSA-87 |
|---|---|---|---|
| JOSE `alg` | `ML-DSA-44` | `ML-DSA-65` | `ML-DSA-87` |
| COSE `alg` | -48 | -49 | -50 |

Key type: `"kty": "AKP"`. Library and identity-provider support for these identifiers was not checked here: check the vendor docs before planning a date.

## Move when both ends support it

Move a token flow to ML-DSA only when the issuer and every verifier support RFC 9964. Run both algorithms side by side during the switch (two keys in the JWKS, verifiers accept both, issuer switches, old key removed later by the human).

## How to prove

P1 (re-scan: `SIG-JWT` findings either closed or `ACCEPTED: <owner, until date>` in `.pqshift.json`) plus P3 (the auth tests pass, including a test that a token with an algorithm outside the allow-list is rejected).
