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 of | Result |
|---|---|
| Authorize with the same idempotency key and identical request | The stored decision is returned; no new decision |
| Authorize with the same key and a different request | 409 conflict |
| Execute of a completed execution | The stored, redacted result; the adapter is not called |
| Execute of a failed or interrupted execution | 409 conflict; the adapter is not called |
| Execute with an approval that was already consumed | Stored 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
| Timing | Outcome |
|---|---|
| Within 130 s, same nonce | Rejected by nonce reservation |
| After 60 s | Rejected by the timestamp window |
| Modified with a new nonce | Signature fails: the nonce is part of the signed input |
| Sent to a different origin | The 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_idandidempotency_key.
Implementation references
Was this page helpful?
Request Integrity
How AgentShield ensures the request that was signed, authorized, approved, and executed is the same request at every step.
SSRF Protection
How the http.request adapter and the network layer prevent agents from reaching internal services, cloud metadata endpoints, and unintended hosts.