Security, Governance and PlatformPlatform contracts and execution isolationPrincipal
Why do valid webhook signatures and recent timestamps not prevent duplicate agent actions?
By Amit Kumar2 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A signed entitlement event starts a grant, but the handler times out after the mutation and the provider retries with a new valid signature. Design durable event admission and effect identity, distinguish fresh provider retries from captured-request replay and handle concurrent handlers, stale events and lost acknowledgments.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
A signature answers who sent these bytes and whether they changed. It does not say this is the first delivery of the business event or that the resulting action is still appropriate. Providers retry webhooks after failures, and an operator may resend an event. In Stripe's webhook documentation, a retry gets a fresh signature and timestamp. That delivery can pass a strict signature and recency check even when the same event was already processed. Stripe also documents tracking event IDs to handle duplicate deliveries.
Imagine an entitlement event starts an agent run. The agent grants access, but the webhook handler times out before returning success. The provider retries. Both signed requests are valid. If the handler starts a fresh run keyed to delivery attempt instead of event identity, the grant action may run again. Sometimes a duplicate grant is harmless. A repeated welcome email, credit or role escalation may not be. Bind a durable inbox record to provider, account and event ID, and atomically claim it before launching downstream work. Give the actual mutation a stable idempotency or operation key as well, since a workflow can retry independently of the webhook.
There is a second issue called replay. An attacker who captured an exact signed request might retransmit it. Check the provider's signed timestamp within a documented tolerance using a sane clock. Do not set a zero tolerance without checking its actual meaning. Stripe's docs warn that zero disables their recency check. Freshness blocks an old captured request, but it does not replace event deduplication because a legitimate retry is freshly signed. Conversely, event deduplication does not prove authenticity. Both controls have jobs.
Deduplication also does not establish event order or current authority. A late grant event must not automatically overwrite a later revocation. Use the provider’s resource version or authoritative-state lookup where its contract supports that decision, and make the mutation conditional on the appropriate lifecycle state. Some providers issue different event IDs for the same business transition, so define the semantic operation identity in addition to the transport event key.
For the test, deliver the same event twice with distinct valid delivery signatures, race two handlers, then crash after the business mutation but before the HTTP acknowledgment. Verify a single durable effect and an auditable record for both deliveries. The webhook JSON is valid. Why does signature verification fail after a refactor? is about verifying the raw webhook bytes after a JSON refactor. This page starts with successful signature verification and asks what prevents repeated authorized work.
Related questions
Keep practising security, governance and platform
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux