BotNetwork

Webhook replay protection

Reject old timestamps and reuse of event ids.

Guide1 min readUpdated

Why it matters

Attackers who capture a valid signed webhook can replay it. Platforms that include timestamps (Slack) expect you to reject skew; all platforms benefit from idempotent event ids.

Practical steps

  1. Reject requests whose timestamp is older than ~5 minutes when the platform provides one.
  2. Store seen event/update ids with a TTL covering the retry window.
  3. Make handlers safe if a duplicate slips through.
  4. Alert on verify_ok + duplicate_id spikes.
  5. Test with a fixture that reuses an id.

Watch out for

  • Only checking signatures and ignoring timestamps.
  • In-memory replay caches that reset on every deploy.

Related comparisons and tools