JWT Algorithm Allowlists for LLM Gateways
A JWT algorithm allowlist for an LLM gateway is a server-side token-profile rule, never a choice delegated to the token header. The verifier must reject every unconfigured algorithm, bind each verification credential to exactly one algorithm, keep JWT classes under mutually exclusive validation rules, and prove those decisions with negative release fixtures.

A token arrives at an LLM gateway with alg set to HS256. The gateway profile accepts only RS256 for that issuer and access-token type. The verifier rejects the token before verification-material lookup or claim acceptance. It performs no route authorization or principal creation, and it does not forward the prompt. It never treats the token's header as permission to choose a different verification method.
That server-side decision is the algorithm allowlist. Its evidence should name the profile and allowed algorithm. It should also identify the selected verification binding and profile version, along with the library version and rejection reason for every altered fixture.
TL;DR
- Configure accepted JWT algorithms in the trusted issuer and token profile. Treat the unverified
algheader only as input to that allowlist. - Bind each verification credential to exactly one algorithm and reject
none, family switches, unsupported parameters, and wrong-token types. - Use mutually exclusive validation rules for access tokens, ID tokens, assertions, and other JWT classes.
- Test the deployed gateway with algorithm substitutions and prove that rejected tokens create zero model dispatches.
The token header never defines local policy
Signed JWTs carry an alg header so a verifier can identify the declared cryptographic operation. That value arrives before signature validation and remains attacker-controlled until verification succeeds. RFC 8725 Section 2.1 records two well-known failure patterns: changing the value to none, and switching an RSA signature profile to HMAC so a vulnerable implementation treats an RSA public credential as a shared HMAC secret.
Section 3.1 of RFC 8725 gives the operational rule. Libraries must let callers specify a supported algorithm set and must refuse every other algorithm. The implementation also has to verify that the header value matches the cryptographic operation performed. Each verification credential must be used with exactly one algorithm, checked during that operation.
The LLM gateway therefore supplies the algorithm policy. The header can select one candidate from the configured set. It can never expand that set. A library call that accepts whatever algorithm appears in the token turns cryptographic agility into caller-controlled authentication.
Build the allowlist around a token profile
Store the allowlist beside a trusted issuer identifier and token type. This record is the token profile, and it also contains the expected audience and verification source. Required claims complete the record. For an OAuth JWT access token, the profile might require typ equal to at+jwt and an exact issuer. It can also require the LLM resource audience, specific time claims, and one asymmetric signing algorithm.
RFC 9068 Section 2.1 says JWT access tokens under that profile must be signed and explicitly typed as at+jwt; none is prohibited. Conforming servers also have to support RS256. Its validation section makes type and exact issuer part of one resource-server contract. The same contract covers audience and signature, plus algorithm and expiration.
A cryptographic library can implement several JOSE algorithms while one issuer profile permits only one.
I would reject a design review if the algorithm list lives only in a framework default. Defaults change during dependency upgrades, and the authentication contract deserves a versioned line of configuration.
The access-token audience validation guide covers the intended-resource check. Algorithm policy supplies one part of that same acceptance contract.
Bind verification credentials to one algorithm
Algorithm allowlisting still fails when a verifier feeds the wrong verification material into the accepted operation. RFC 8725 requires each credential to serve exactly one algorithm. Enforce that binding in trusted configuration and at the final cryptographic call.
For a JWK, inspect its type and the profile's approved use. RFC 7517 Section 4.2 defines use values such as sig and enc. Section 4.3 defines key_ops, including verify, and warns against unrelated operations on one credential. Section 4.4 defines the optional JWK alg parameter.
Local policy should require consistency between the token profile and JOSE alg. It should also check the JWK type and optional JWK alg, then confirm the permitted operation. A missing optional JWK field never grants broad use. The profile still supplies the binding. A conflicting field produces a closed result.
Keep symmetric and asymmetric verification paths separated in code and configuration. An RSA public credential should never enter an HMAC verification function. Distinct stores or typed credential objects make that mistake harder than a generic byte buffer shared across algorithm families.
The LLM JWT issuer validation guide explains why the verification set must also remain bound to the selected issuer.
Separate JWT classes before cryptography
One issuer may create several credential classes. These can include access and ID tokens, logout artifacts, client assertions, and internal request JWTs. A valid signature on one class gives it no authority in another. RFC 8725 Section 3.12 requires mutually exclusive validation rules when an issuer creates multiple JWT kinds.
Use explicit type values where the profile defines them. Add distinct required claims and audiences. Issuers and header parameters can provide further separation, as can dedicated verification credentials, so the wrong class fails the target profile. This is a stronger release artifact than a single global algorithm list because it proves which token population the gateway accepts.
For an LLM access route, resolve the intended profile from trusted listener and route configuration. Parse enough protected header data to identify the declared type and algorithm, then compare them with the selected profile before expensive work. Complete signature and claim validation before creating a principal.
Avoid trying every profile and every verification credential until something validates. That approach increases ambiguity and can let a token cross classes through a permissive fallback. Return a stable authentication failure when profile selection is missing or ambiguous. Contradictory and inconsistent selections produce the same failure.
The duplicate JSON member policy matters here because duplicated JOSE header names can create parser disagreement. The JWS validation procedure requires a valid JOSE header without duplicate parameter names.
Algorithm agility needs a controlled migration
Cryptographic agility means the deployment can change approved algorithms as security requirements evolve. It never means accepting every algorithm a library knows. A migration should create an explicit overlap period with two independently configured verification bindings, followed by removal of the old profile entry.
Record the proposed algorithm and issuer support. Document credential provenance and library support, including hardware or credential-management requirements. Add the rollout order and rollback condition, then set the final removal date. Test old and new tokens against each deployment stage. During overlap, each token still has to match one profile and one algorithm binding.
Section 3.2 of RFC 8725 requires applications to use cryptographically current algorithms that satisfy their security requirements and to support future algorithm change. The standard leaves the deployment's acceptable set to its context. Avoid claiming that one algorithm is universally mandatory outside a named JWT profile.
Pin dependency versions during the migration and review release notes for changes to accepted algorithms and verification-material parsing. Check signature formats and defaults as separate release concerns. A library update should never add an algorithm to production policy without a configuration change and a negative fixture.
Negative fixtures decide release
Build a valid token fixture for the exact issuer and type. Set the intended audience and claims, then use the allowed algorithm and verification credential. Then alter one property at a time while keeping the rest controlled. This makes each rejection attributable.
The suite should include:
- Replace the allowed algorithm with
noneand remove the signature. The verifier rejects it under the profile. - Change
RS256toHS256while presenting the RSA public material as the HMAC input to a deliberately adversarial fixture. The production verifier refuses the family switch. - Declare an algorithm outside the profile that the underlying library still implements. Local policy rejects it.
- Keep the header algorithm while signing with another operation. Signature validation fails without fallback.
- Select a credential whose optional JWK
algor type conflicts with verification policy. Repeat the check for conflicts inuseandkey_ops. - Present a valid ID token under the access-token route. Mutually exclusive profile rules reject it.
- Present an allowed algorithm and valid signature from the wrong issuer verification set. Issuer binding rejects it.
- Exercise malformed and duplicate protected header fields. Cover oversized tokens and missing type in separate cases. Add cases for an unknown credential ID and unsupported critical parameters.
Run these fixtures through the deployed ingress and authentication middleware. Continue through route policy and the provider adapter, then verify the audit path. Unit tests around a JOSE helper catch implementation errors. Production-topology tests catch a permissive proxy or stale replica. They also expose a divergent worker or alternate listener.
During review, place a red card beside each rejected fixture in the test output. The card should show the token-profile version and observed alg. It should identify the selected credential or show a no-credential result. Add the verifier reason and provider dispatch count of zero. That visible line is more useful than a green test named "JWT security."
Evidence should preserve the decision without the token
Record the trusted issuer policy ID and token type. Include the observed algorithm and allowed algorithm-set version. Identify the selected credential by thumbprint or stable internal identifier, and record the verification-set version. Preserve the verification result and claim-validation result. Finish the event with the route and timestamp. Store a one-way token fingerprint for correlation. Exclude raw bearer credentials and private or symmetric verification material.
Protected reasons should distinguish a blocked algorithm, an operation mismatch, incompatible credential use, a wrong token class, and a bad signature. The public response can use the route's standard invalid_token challenge. Detailed reasons belong in access-controlled telemetry.
Monitor rejection changes after configuration and dependency releases. A sudden drop in alg_not_allowed paired with broader acceptance can indicate policy drift. A surge may show an issuer migration or client misconfiguration. The metric supports investigation, while the per-request event proves the actual decision.
DeepInspect
The authorization server and resource-server verifier own JWT type selection and algorithm configuration. They also own credential custody and signature validation. Claims, revocation, and authentication challenges remain part of that verifier responsibility. DeepInspect should receive validated identity context for authenticated user or agent requests deliberately routed through its HTTP path to an LLM endpoint. It should never be described as the JWT cryptographic verifier without a documented integration proving that role.
For a validated request, DeepInspect can apply identity-aware policy to the route and model. The same decision can account for tenant and tool, plus the data classification, then produce a separate per-request decision record. A correlation reference can join that record to the authentication event. Direct provider calls and local inference remain outside this evidence chain. STDIO execution and traffic that bypasses the routed gateway are also outside it.
Book a demo today.
Frequently asked questions
- Should an LLM gateway trust the alg value in a JWT?
The gateway reads
algas unverified input and compares it with the server-configured token profile. It uses the value only after confirming that the profile permits it and the selected credential is bound to that operation. The header never creates local permission. A mismatch or unsupported value ends authentication before claim acceptance and model-route policy.- Is rejecting none enough to prevent algorithm confusion?
Rejecting
nonecloses one historical failure. A complete defense fixes the allowed algorithm set and separates symmetric from asymmetric verification paths. It also binds each credential to one algorithm and verifies that the declared operation matches the performed operation. Mutually exclusive token-profile rules close the remaining class boundary. The RSA-to-HMAC family switch demonstrates why anonecheck alone leaves another path open.- Can one issuer profile allow several algorithms?
A profile can permit several algorithms during a controlled migration or when the issuer contract genuinely supports them. Each selected credential still needs one algorithm binding, and every combination needs positive and negative tests. Keep the set as small as the deployment requires. Record its version and removal date for transitional entries so overlap never becomes an undocumented permanent state.
- Does RS256 support mean every route should accept RS256?
Library or profile support expresses capability. Route acceptance comes from the selected issuer and token profile. RFC 9068 requires conforming JWT access-token implementations to support
RS256, while a particular deployment can negotiate and configure its actual signing policy under that profile. Avoid transferring one profile's requirement to unrelated JWT classes.- Where should the algorithm allowlist live?
Place it in versioned, server-side authentication configuration associated with the issuer and token type. Bind the same configuration to the audience and verification source, then assign it to the route group. Feed the explicit set into the JOSE library on every validation path. Include startup validation that rejects ambiguous or conflicting credential bindings. The release record should identify the policy version that produced each authentication result.