Skip to Content
AgentShield
Security

Replay Protection

How nonces, timestamps, idempotency keys, and execution claims together prevent a captured or repeated request from acting twice.

A signature proves a request came from the agent. It does not prove the request is new. AgentShield layers three mechanisms so that replaying a request, whether by an attacker or a buggy retry, never causes a second action.

Layer 1: Timestamp window

The signed timestamp must be within 60 seconds of the gateway clock, in either direction. A request captured and replayed later than that fails signature verification with 401. Clock skew beyond 60 seconds is a denial, not a retry.

Layer 2: Nonce reservation

Immediately after the signature verifies, the gateway reserves the nonce in Redis:

SET agentshield:v1:nonce:<agent id>:<nonce> 1 NX EX 130
  • If the key already exists, the request is a replay: 401 unauthenticated, "nonce already used".
  • The reservation lasts 130 seconds, longer than the full ±60-second acceptance window, so a nonce cannot be reused while its timestamp could still be accepted.
  • Nonces are scoped per agent.
  • If Redis is unavailable, the request fails with 500. It is never accepted without a reservation.

Nonces must match ^[A-Za-z0-9_-]{16,128}$. The SDKs generate 16 random bytes, base64url-encoded, for every request.

Layer 3: Idempotent decisions and executions

Replay protection at the transport layer is complemented by idempotency at the data layer:

Repeat ofResult
Authorize with the same idempotency key and identical requestThe stored decision is returned; no new decision
Authorize with the same key and a different request409 conflict
Execute of a completed executionThe stored, redacted result; the adapter is not called
Execute of a failed or interrupted execution409 conflict; the adapter is not called
Execute with an approval that was already consumedStored result if completed; otherwise refused

Even a correctly signed, fresh request cannot make a single decision run twice.

What an attacker can do with a captured request

TimingOutcome
Within 130 s, same nonceRejected by nonce reservation
After 60 sRejected by the timestamp window
Modified with a new nonceSignature fails: the nonce is part of the signed input
Sent to a different originThe SDKs refuse redirects; a signed request is not forwarded

Operational considerations

  • Clock sync. Keep agent hosts and gateways on NTP. Requests from a host more than 60 seconds off are rejected.
  • Redis durability. Nonces are short-lived. A Redis flush or failover that loses keys reopens replay for requests whose timestamps are still inside the 60-second window. Use a Redis deployment with persistence or replication appropriate to your risk.
  • Retries. A client retry must use a new nonce and signature. To make a retried authorize idempotent, reuse the same execution_id and idempotency_key.

Was this page helpful?

On this page