← Blog

JWT jti Replay Cache for LLM Requests: The Acceptance Evidence That Proves Single Use

Parminder Singh
Parminder Singh··8 min read
Summarize with AI

A JWT jti replay cache can enforce single use only when the token profile defines single-use semantics and the verifier makes an atomic first-seen decision. This guide specifies the release evidence for authenticated user or agent requests to an LLM, including validation order, cache identifiers, expiry, concurrency, replica behavior, outage handling, and audit records.

Platform & Architectureai-securityllm-securityjwtidentity-and-authorizationzero-trustaudit-evidence
JWT jti Replay Cache for LLM Requests: The Acceptance Evidence That Proves Single Use

A JWT reaches an LLM gateway with a jti claim set to f47c2a. The verifier accepts the signature, issuer, audience, and time claims, then attempts an atomic insert of the issuer and JWT ID into a replay store. Whichever request completes that insert first may continue. A second authenticated request carrying the same one-time token gets a replay rejection before its prompt reaches the model.

That mechanism sounds small, but the release evidence has to prove far more than the presence of a cache. The team needs to show that the token was intended for single use, validation shields the store from forged tokens, concurrent duplicates produce one winner, every gateway replica shares the same decision, and cache failure produces the documented result.

TL;DR

  • A jti identifies a JWT. Single-use enforcement requires a verifier policy and an atomic first-seen record.
  • Apply replay rejection only to a token profile that explicitly requires single use. Ordinary bearer access tokens may be presented more than once.
  • Acceptance evidence should cover validation order, cache identifier scope, expiry, concurrent duplicates, multiple replicas, restart behavior, and cache outages.
  • Keep bearer-token replay controls distinct from DPoP proof-of-possession. They solve different problems and produce different evidence.

A JWT ID is one input to replay policy

Section 4.1.7 of RFC 7519 defines jti as an optional, case-sensitive unique identifier. Its value must have a negligible probability of accidental reuse, including collisions across multiple issuers, and the RFC says it can be used to prevent replay. The standard leaves the prevention mechanism to the application.

This creates the first acceptance question: which JWT profile is the cache enforcing. A reusable bearer access token may legitimately appear on many model requests until expiry. Rejecting its second presentation silently converts it into a one-time credential and breaks the calling contract. A request-specific JWT assertion, delegated authorization envelope, or other profile can require single use, but that requirement needs to appear in the issuer-verifier contract.

Write the contract down before testing. Name the token type and trusted issuer. Record the intended audience and accepted algorithms, plus required claims and maximum lifetime. State that a successful presentation consumes the token. Define the rejection result for a duplicate and identify the service that owns the replay store.

The identity-aware AI gateway architecture covers the wider identity and policy path. This narrower acceptance gate proves that one token profile receives one successful presentation at one authenticated user or agent to LLM HTTP boundary.

Validation must precede cache consumption

A replay cache can become a denial mechanism when an untrusted value reserves a valid identifier. An attacker who knows or predicts a future jti could submit a forged JWT first. If the verifier writes that identifier before authenticating the token, the legitimate request later looks like a replay.

RFC 8725 Sections 3.1, 3.3, 3.8, and 3.9 require algorithm verification, validation of all cryptographic operations, binding issuer claims to the correct verification material, and audience validation where an issuer serves more than one relying party. Apply those checks before the atomic replay decision. Enforce exp and nbf under the token profile as well. The time-claim provisions in RFC 7519 define exp, nbf, and iat, with a small implementation-defined allowance for clock skew.

A defensible processing order for the release candidate is:

  1. Bound the token size and parse its protected header and claims.
  2. Select an allowed algorithm and trusted verification material for the claimed issuer.
  3. Verify every cryptographic operation required by the token profile.
  4. Validate token type, issuer, subject rules, audience, exp, nbf, and required jti.
  5. Derive the replay identifier from the validated token context.
  6. Claim that identifier through one atomic first-seen operation.
  7. Continue to authorization and the LLM route only after the claim succeeds.

The replay identifier should include enough validated namespace to prevent unrelated issuers or token profiles from interfering with each other. A typical local design uses the trusted issuer, explicit token type or profile, intended protected service, and jti. Hashing the bounded composite before storage limits identifier size and avoids copying raw token material into the cache. RFC 7519 leaves those exact fields to deployment policy, so preserve them in the acceptance specification.

The atomic first-seen test decides release

A read followed by a write leaves a race. Two requests can both observe an empty entry and both proceed. The acceptance test needs a single atomic operation with two outcomes: this request created the replay record, or an earlier request already owns it.

Run the test against the deployed load balancer, using the public route that production callers will reach. Send a valid one-time JWT once and retain the request ID, validated issuer, audience, token profile, hashed replay identifier, cache operation result, cache expiry, policy version, route decision, and timestamp. Present the identical token a second time through that route. The duplicate must stop before model dispatch and record a stable replay reason.

Then launch a concurrent burst using the same token. Exactly one request may pass the first-seen gate. Every other request must receive the documented duplicate result, and provider-side evidence must show one model dispatch. I would reject a release over two successful rows with the same replay identifier, even if the prompts produced harmless output.

Put two terminal windows side by side during review. The left window should show the winning atomic insert and model request ID. The right should show the same hashed replay identifier, an existing-entry result, and no provider request ID. Those paired lines expose the component that stopped the duplicate.

Expiry evidence must match the token contract

A replay record that disappears too early reopens the accepted replay window. A fixed cache duration measured from first presentation can be unsafe when the token remains valid beyond that duration. Derive the record expiry from the validated token's acceptance horizon, including the verifier's documented clock-skew allowance. The stored value can remain minimal: first-seen time, expiry, token profile, and a correlation reference are usually enough for the decision.

Test the boundary with controlled clocks. Present a token just before expiry, repeat it while the verifier would still accept its time claims, and confirm the replay record remains effective. After the complete acceptance horizon ends, the token should fail time validation regardless of cache state. Record both reason codes so an auditor can distinguish an expired token from a duplicate valid token.

Capacity behavior also belongs in the evidence pack. Measure the store under the expected volume of unique accepted and rejected identifiers. Bound jti length before identifier construction. Demonstrate the eviction policy cannot remove live replay entries merely because the cache reaches a memory threshold. If the implementation stores digests, document the hash algorithm and input framing so every replica derives the same identifier.

Replica, restart, and outage tests expose false confidence

A production LLM route often has several verifier replicas. Process-local memory lets a replay move to another node and appear new. Pin the first request to replica A and route its duplicate to replica B. Repeat the case during a rolling restart and during a cache-node failover. Each duplicate must encounter the first-seen record until the token's acceptance horizon closes.

The outage rule must be decided before the cache disappears. For a route that promises single-use JWTs, allowing traffic while the replay store is unavailable suspends that promise. A fail-closed result should carry a separate reason such as replay-state unavailable, which avoids mislabeling the request as a confirmed replay. Track cache latency and availability without treating a successful health check as proof of atomic behavior.

The acceptance pack should include these artifacts:

  • The versioned token-profile contract and verifier configuration.
  • A redacted valid token showing issuer, audience, time claims, type, and jti.
  • First-use and exact-replay records joined by the hashed replay identifier.
  • Concurrent duplicate results showing one winner and one provider dispatch.
  • Cross-replica, restart, failover, and cache-outage results.
  • Expiry-boundary evidence tied to token expiry and clock-skew policy.
  • A signed release disposition naming the identity-service owner and exception owner.

The AI audit log schema guide provides the wider per-request record. Keep the replay identifier hashed and retain the verifier reason beside the model-route decision. Never store the complete bearer token merely to simplify test reconstruction.

Bearer replay and DPoP proof replay are separate controls

A jti replay cache for a single-use bearer JWT rejects reuse of that token identifier. Bearer presentation proves access to the token while leaving private-key possession unproven. Whoever possesses a valid bearer token can win the first-use race, which means token confidentiality, short lifetimes, audience restriction, and secure delivery remain part of the design.

DPoP in RFC 9449 adds a signed proof bound to an HTTP method, target URI, creation time, access-token hash, and client public key. Its proof replay provisions discuss tracking a DPoP proof's jti during its acceptance window, while also noting the shared-state difficulty across multiple servers. DPoP proof identifiers therefore belong to a DPoP proof cache with DPoP-specific validation and a separate namespace from bearer JWT replay records.

The operational difference appears in retry behavior. The RFC 9449 client considerations recommend generating a fresh DPoP proof when retrying, even for an otherwise idempotent request. A one-time bearer JWT profile may require the caller to obtain a new request token. The DPoP tokens for AI agents guide owns the proof-of-possession test pack. This guide owns acceptance evidence for the narrower single-use JWT cache.

DeepInspect

DeepInspect operates on authenticated HTTP traffic deliberately routed between users or agents and LLM endpoints. A stateful JWT replay cache belongs with the identity verifier or authentication gateway that validates the token profile before the model request reaches DeepInspect. Direct provider calls and local inference bypass this route and need separate controls.

For requests that pass upstream authentication, DeepInspect can evaluate the supplied identity context, prompt classification, model destination, and versioned policy. Its independent decision record can carry a correlation reference to the verifier's first-use result. The verifier record proves the single-use token decision. The DeepInspect record proves the policy decision on the routed LLM request. Keeping those records separate gives an investigator a clean chain without pretending a stateless policy gateway owns replay state.

Book a demo today.