Webhook Signature Verification Implementation Checklist Builder

Build an implementation checklist for signed webhook verification, timestamp tolerance, replay protection, secret handling, tests, and observability.

Prompt Template

You are a backend security engineer helping implement signed webhook verification.

Webhook provider: [Stripe, GitHub, Shopify, Slack, custom provider, other]
Application stack: [Node, Python, Ruby, Go, PHP, Java, serverless, framework]
Webhook endpoint path: [URL/path]
Signature scheme: [header names, HMAC algorithm, timestamp format, signed payload format]
Provider documentation notes: [paste relevant signing docs]
Raw request body handling: [framework behavior, middleware, body parser, encoding]
Secret storage: [environment variable, secret manager, rotation process]
Replay protection requirements: [timestamp tolerance, nonce/event ID store, duplicate handling]
Event processing model: [synchronous, queue, background worker, idempotency key]
Failure behavior: [HTTP status codes, retries, dead-letter queue, alerting]
Test environment: [local tunneling, staging, provider test events]
Compliance or audit needs: [SOC 2 evidence, security review, change control]

Create:
1. Implementation checklist for raw body capture, canonical string construction, HMAC comparison, and constant-time checks.
2. Framework-specific pitfalls for the provided stack.
3. Replay protection design with timestamp tolerance, event ID tracking, and storage TTL.
4. Secret handling and rotation plan that supports old and new secrets during migration.
5. Error handling rules for missing headers, stale timestamps, invalid signatures, and malformed payloads.
6. Unit, integration, and provider test cases with sample fixtures.
7. Observability plan for signature failures without logging secrets or full sensitive payloads.
8. Deployment checklist for staging, production, rollback, and monitoring.
9. Security review questions and evidence to capture.
10. Pseudocode or code outline appropriate for the stack.

Keep the guidance specific to signature verification and replay defense. Do not expose secret values or log raw sensitive payloads.

Example Output

Verification Flow

| Step | Check | Failure Response |

|---|---|---|

| 1 | Capture raw request body before JSON parsing | 400 malformed request |

| 2 | Read timestamp and signature headers | 401 missing signature |

| 3 | Reject timestamps older than 5 minutes | 401 stale webhook |

| 4 | Build canonical string exactly as provider documents | 401 invalid signature |

| 5 | Compare HMAC using constant-time comparison | 401 invalid signature |

| 6 | Store event ID for 24 hours before processing | 200 duplicate ignored |

Test Cases

- Valid provider fixture passes verification.

- Same JSON reserialized with different whitespace fails if raw-body handling is wrong.

- Timestamp outside tolerance is rejected.

- Replayed event ID is acknowledged but not processed twice.

Logging

Record provider, event type, endpoint, failure reason, and request ID. Do not log signing secrets, computed signatures, or full payloads with personal data.

Tips for Best Results

  • 💡Most webhook signature bugs come from parsing or mutating the body before verification.
  • 💡Treat replay protection separately from idempotent business processing; you usually need both.
  • 💡Use provider fixtures in tests so future framework upgrades do not silently break verification.
  • 💡Log enough to debug failures without turning webhook payloads into a sensitive data dump.