ecdsa.com
jose (JavaScript)JWT libraries

Error message

"alg" (Algorithm) Header Parameter value not allowed

jose (JavaScript) — JOSEAlgNotAllowed, code ERR_JOSE_ALG_NOT_ALLOWED

What it means

The token's alg header names an algorithm that is not in the algorithms allowlist you passed to jwtVerify, or does not match the key's declared algorithm. jose refuses before any cryptography runs. This gate is deliberate: the alg header is attacker-controlled input, and the verifier — not the token — must choose the algorithm.

Why it happens

How to fix it

  1. 1.

    Align allowlist, key and issuer configuration

    Look at the header, then make all three agree. During migrations, accept both algorithms temporarily, each served by its own key via JWKS kid.

    js
    import { decodeProtectedHeader, jwtVerify } from "jose";
    
    console.log(decodeProtectedHeader(token)); // { alg: "ES256", kid: "..." }
    await jwtVerify(token, jwks, { algorithms: ["ES256"] });
  2. 2.

    Keep the allowlist as small as possible

    Do not "fix" this error by listing every algorithm. One value per token type is the safe end state; RFC 8725 (JWT Best Current Practices) says the same.

    js
    // good: exactly what your issuer signs with
    { algorithms: ["ES256"] }
    // bad: defeats the protection this error provides
    { algorithms: ["ES256", "RS256", "HS256", "PS256"] }

Related errors

← Browse the full signature error database