I am not a cybersecurity expert.
This workflow was built through research and with the assistance of an LLM (Claude Opus 4.6).
While it implements well-established security patterns (HMAC-SHA256, timing-safe comparison, replay protection, strict payload validation), please review the logic carefully and ensure it meets your own security requirements before deploying it in production.
This template is for anyone exposing an n8n workflow via webhook and wanting to ensure that only authenticated, untampered requests are processed.
Public webhooks are vulnerable by default. Without proper verification, anyone who discovers your URL can send forged requests, replay old ones, or inject unexpected parameters.
While n8n's built-in Webhook authentication modes (Basic Auth, Header Auth, JWT) verify who is calling, they don't verify that the payload hasn't been altered, that the request is fresh, or that the data structure matches what you expect.
This template adds those missing layers:
The workflow chains six security layers before any business logic runs:
{timestamp}.{rawBody} using your HMAC secretcrypto.timingSafeEqual()Invalid requests are immediately rejected with 403 Forbidden (signature/timestamp failure) or 400 Bad Request (payload validation failure), with no response body to avoid leaking internal logic.
The included example protects an AI Agent endpoint that expects a simple {"prompt": "..."} payload. But this is just a starting point — replace the AI Agent with any node and adapt the payload validation to your own schema.
Common adaptations:
This workflow is a solid starting point — it's more secure than a raw exposed webhook.
However, it focuses on application-level security (authentication, integrity, replay protection, payload sanitization).
For a production-grade setup, consider adding layers at the infrastructure level :