Webhook security checklist: 12 checks before you ship
Webhook security rests on five basics: verify the signature, keep the raw body, enforce a timestamp window, handle events idempotently, and answer 200 quickly.
Verification
- Always verify the signature. Reject failures with 401 and do not process the body.
- Keep the raw bytes. Apply raw-body settings to the route and verify before parsing.
- Compare in constant time. Use the language helper instead of string
==. - Check the timestamp window. 300 seconds for Stripe, Slack and Toss Payments; without one, deduplicate by event ID.
- Keep secrets out of code. Environment variables or a secrets manager only.
Processing
- Make it idempotent. Deduplicate by eventId or delivery ID.
- Answer 200 quickly. Move heavy work to a queue and respond within ten seconds.
- Make failures retryable. 5xx for transient errors, 4xx for permanent ones.
- Do not assume order. Drop stale events using their created time.
Operations
- Design for secret rotation. Accept both secrets briefly during a switch.
- Do not over-log bodies. Mask personal and payment data; log hashes and byte counts.
- Monitor. Watch the 401 rate, processing delay and retry counts.
What each response code means
| Code | Meaning | Sender behaviour |
|---|---|---|
| 200 | received and verified | stops retrying |
| 401 | signature mismatch | usually does not retry |
| 400 | malformed body | does not retry |
| 429 | rate limited | retries |
| 5xx | transient failure | retries |
Returning 5xx for a verification failure makes the sender keep retrying a forged request. Use 401.
Final check
After deployment, use the provider's test event to confirm four things: a valid signature passes, an altered body is rejected, the same event sent twice is processed once, and a request older than the window is rejected. Those four mean the basics are covered.
Apply the checklist, then confirm the real request with the verifier.
Open the signature verifierFrequently asked questions
If the webhook URL is secret, do I need signatures?
Yes. URLs leak through logs, browsers and proxies, and anyone with the URL can post to it. Signature verification is the baseline.
Is an IP allowlist enough?
It is a useful secondary control when the sender publishes stable IPs, but cloud senders change ranges, so it cannot replace signatures.
Should I store the body?
Often yes, for reprocessing. Encrypt or mask personal and payment data and set a retention period.
This guide follows the signing schemes published by GitHub, Stripe, Slack, Shopify and Toss Payments.
← Guides