Case Study: Zero-Trust Webhook Ingress (Stripe & GitHub)
This case study demonstrates how to protect payment gateways and webhook ingestion endpoints from unauthorized tampering, forged payload injection, and internal route disclosure.
The Threat Model
Modern SaaS and e-commerce applications rely heavily on external webhooks from services like Stripe, GitHub, Shopify, Paddle, and Slack.
Because webhook handlers must be reachable over the public internet, developers frequently place their entire payment or integration microservice behind Traefik. This exposes several risks:
- Reconnaissance of Internal Endpoints: Attackers probe
/webhooks/debug,/webhooks/replay, or/webhooks/test. - Forged Event Injection: Direct HTTP spam to the webhook receiver attempting to trigger expensive verification workflows or crash background queues.
- Credential & Config Exposure: Accidental leakage of
.envor deployment configurations on webhook servers.
The Solution: Two-Layer Zero-Trust Defense
With Routewarden, you enforce a two-tier gatekeeper at the edge:
- IP Range Restriction (
allowedIps): Only official CIDR blocks published by Stripe/GitHub can send payloads to/webhooks/.*. - Exact Allowlist (
allowPatterns): Only designated production webhook endpoints (e.g./webhooks/stripe/v1) are permitted; all internal or debug paths are blocked with404 Not Foundor dropped silently (silentDrop).
Configuration (Traefik, Caddy & NGINX)
# dynamic_conf.ymlhttp: middlewares: webhook-shield: plugin: routewarden: enabled: true methods: - GET - POST - PUT - DELETE - PATCH - HEAD enableDefaultPatterns: true # 1. Zero-Trust Allowlist: permit strictly verified production webhook handler allowPatterns: - '(?i)^/webhooks/stripe/v1$' # 2. Catch-all: default-deny all other webhook routes blockPatterns: - '(?i)^/webhooks(/.*)?$' # Restrict to official Stripe Webhook IP ranges allowedIps: - "3.18.12.63/32" - "3.130.192.231/32" - "13.235.14.237/32" - "13.235.122.149/32" - "35.154.171.200/32" response: mode: silentDrop # Drop unauthorized scanner connections immediately routers: webhook-router: rule: "Host(`api.example.com`) && PathPrefix(`/webhooks`)" entryPoints: - websecure middlewares: - webhook-shield service: webhook-serviceIMPORTANT
HTTP Methods Requirement: Webhook providers (such as Stripe, GitHub, Shopify, and Paddle) exclusively deliver event notifications using POST requests. Because Routewarden inspects only GET requests by default, always explicitly define methods GET POST PUT DELETE PATCH HEAD (or methods: ["GET", "POST"]) so inbound webhook traffic and probes are evaluated against your allowlist and CIDR restrictions.
WARNING
Edge Proxy & CDN Compatibility: When using mode: silentDrop behind an edge proxy or CDN (such as Cloudflare, Traefik edge, AWS ALB, or NGINX reverse proxy), dropping the TCP connection abruptly will cause the edge proxy to report an HTTP 502 Bad Gateway error to unauthorized clients. If you want stealth deflection without triggering edge proxy 502 errors, use mode: json or mode: html with statusCode: 404 instead.