Requex.me LogoRequex.me

Documentation

Browse by section

Keep all guides, tool docs, automation recipes, and comparison pages in one navigable place.

Docs Home
Docs

Foundation docs for getting started fast, understanding key terms, and tracking what has changed.

Guides

Start with fundamentals, then move into provider-specific webhook testing and production hardening.

Tool Docs

These pages explain what each tool does, when to use it, and how it fits into a webhook debugging workflow.

Automation Docs

Use these setup guides when you want forwarding rules, custom responses, security checks, or multi-destination fanout.

Compare

Use these pages to compare developer workflows, pricing tradeoffs, and feature differences between webhook tools.

Webhook Security Best Practices for Developers

How to secure your webhook endpoints against spoofing, replay attacks, and unauthorized access — covering HMAC signature verification, timestamp validation, and rate limiting.

Last updated: February 2026 • 14 min read

The Attack Surface

Your webhook endpoint is a publicly accessible URL that accepts HTTP POST requests from external services. Without verification, anyone who finds that URL can send arbitrary payloads: a spoofed Stripe event claiming a payment succeeded, a replayed GitHub event triggering a deployment, or a flood of fake events overwhelming your queue.

The countermeasures are well-established and not especially complex to implement. The gap between a vulnerable and a secure webhook endpoint is typically a few dozen lines of code.

1. Always Use HTTPS

This is non-negotiable. Your webhook endpoint must use HTTPS (TLS/SSL) to encrypt data in transit. Without HTTPS, the entire webhook payload — including sensitive data like customer information, payment details, or authentication tokens — is transmitted in plain text and can be intercepted by anyone on the network path.

Most reputable webhook providers (Stripe, GitHub, Shopify) will refuse to send webhooks to HTTP endpoints in production. Even during development, use tools like Requex.me which provides HTTPS endpoints by default, so you can test your integration securely from day one.

⚠️ Warning: Never accept webhook traffic over plain HTTP in production. Even for internal services, TLS should be enforced to prevent man-in-the-middle attacks.

2. Verify Webhook Signatures (HMAC)

Signature verification is the most important security measure. Most webhook providers include a cryptographic signature in the request headers, computed using a shared secret and the request body. Your server must recompute this signature and compare it to the one in the header.

The standard approach uses HMAC-SHA256. The provider computes HMAC-SHA256(webhook_secret, raw_request_body) and sends the result in a header (e.g., X-Signature-256). Your server does the same computation and compares. If they match, the request is authentic.

// Node.js HMAC verification example
const crypto = require('crypto');

function verifyWebhookSignature(payload, signature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(payload, 'utf8')
    .digest('hex');
  
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}

Always use crypto.timingSafeEqual() for comparison instead of === to prevent timing attacks.

3. Prevent Replay Attacks with Timestamps

Even with signature verification, an attacker could intercept a legitimate webhook and replay it later. To prevent this, most providers include a timestamp in the webhook payload or headers. Your server should reject any webhook where the timestamp is older than a reasonable window (typically 5 minutes).

Stripe, for example, includes a t= parameter in their signature header. When verifying the signature, you also check that the timestamp is within your tolerance window. This simple check prevents replay attacks with minimal implementation effort.

4. Implement Idempotency

Webhook providers guarantee at-least-once delivery, meaning you may receive the same event multiple times due to network issues or provider retries. Your webhook handler must be idempotent: processing the same event twice should have the same result as processing it once.

The simplest approach is to store a list of processed event IDs. Before processing any webhook, check if you've already handled that event ID. If so, return a 200 OK and skip processing. Most providers include a unique event identifier (e.g., Stripe's evt_xxx) in every webhook payload.

Use a database table or Redis set to track processed events. Clean up old entries periodically (e.g., delete entries older than 7 days) to prevent unbounded growth.

5. Rate Limit Your Endpoint

Even authenticated webhooks can overwhelm your server if too many arrive simultaneously. Implement rate limiting on your webhook endpoint to prevent abuse and protect your infrastructure. A good starting point is 100-500 requests per minute per endpoint, depending on your expected volume.

If you receive webhooks beyond your rate limit, return a 429 Too Many Requests status code. Most providers will respect this and retry later with exponential backoff.

6. IP Whitelisting

Some providers publish a list of IP addresses from which they send webhooks. You can configure your firewall or application to only accept requests from these known IPs. This adds an extra layer of defense, especially for high-security environments.

However, IP whitelisting should be used as a supplementary measure, not a replacement for signature verification. IP addresses can change, and relying solely on IP filtering is fragile.

7. Keep Your Signing Secret Safe

Your webhook signing secret is the key to your security. Treat it like a password. Store it in environment variables, never commit it to version control, and rotate it periodically. If you suspect your secret has been compromised, regenerate it immediately in your provider's dashboard.

Use a secrets manager (like AWS Secrets Manager, HashiCorp Vault, or Doppler) in production environments to centralize and secure your webhook secrets.

Security Checklist

  • HTTPS enforced on all webhook endpoints
  • HMAC signature verification implemented
  • Timestamp validation (reject events older than 5 min)
  • Idempotency checks using event IDs
  • Rate limiting on webhook endpoints
  • Signing secrets stored in environment variables
  • Respond 200 quickly, process asynchronously
  • Comprehensive logging for audit trails

Testing Webhook Security

Use Requex.me to test your webhook security implementation. Send test requests with valid and invalid signatures to verify your verification logic. Simulate replay attacks by resending captured payloads. Configure custom response codes to test your provider's retry behavior.

For a complete testing walkthrough, see our Complete Webhook Testing Guide.

Related Resources

Test Your Webhook Security

Generate a free test URL and verify your security implementation works correctly.

Open Webhook Tester →