Back to Puzzle Catalog Puzzle #66 · Enterprise Security

Secure n8n Webhook Intake Guard

A production-grade, defense-in-depth intake architecture designed to verify trust before allowing any external event into the system. It enforces Header Auth credentials, CORS origin whitelisting, cryptographic HMAC-SHA256 integrity, and strict timestamp freshness (±300s window to eliminate replay attacks) while failing closed on any deviation.

Server Epoch: 0
Replay Window Tolerance: ±300s (5m)
Mode: Fail-Closed / Constant-Time HMAC
Live n8n Execution Canvas
Mirrors production n8n topology: Webhook → Edit Fields → Crypto → If → If1 → Responses
Webhook
POST · Header Auth & CORS
Gate 1: Guarded
Edit Fields
manual · canonical prep
Gate 2: Parse
Crypto
hmac · SHA256
Gate 3: Compute
If
sig === computed?
Gate 4: Check
Respond to Webhook
HTTP 401 Unauthorized
Sig Mismatch
If1
drift ≤ 300s?
Gate 5: Freshness
Respond to Webhook1
HTTP 202 Accepted
Verified
Respond to Webhook2
HTTP 403 Forbidden
Replay / Expired
Attack & Scenario Simulator
Client Dispatcher
-600s +600s
Cryptographic Integrity & Intake Audit
Real-Time State
Canonical signedPayload = ${timestamp}.${body} Edit Fields Node
--
Incoming X-Signature (Header) MATCH
--
Computed HMAC-SHA256 (Crypto Node) Expected
--
INSPECTION TRACE (AUDIT SEPARATION)
Respond to Webhook Output
HTTP 202 ACCEPTED
// Ready to inspect dispatch result...

        
Enterprise Webhook Security Blueprint

1. Header Auth & CORS

Blocks unauthenticated callers at the edge before n8n spends compute resources. Restricts browser origins to prevent CSRF cross-origin injections.

2. HMAC-SHA256 Integrity

Hashes the combined timestamp + payload using a shared secret. Guarantees that neither the body parameters nor the event metadata were tampered with in flight.

3. Replay Protection (±300s)

Prevents attackers from recording valid transmissions and repeating them. Any request older or newer than 5 minutes is rejected with HTTP 403.

4. Fail-Closed Architecture

Missing headers, corrupt JSON, or signature mismatches trigger immediate termination. Unverified events never propagate downstream to business workflows.

Copied to clipboard!