How-to

n8n Webhook Security: Header Auth, Signatures and IP Allowlists, Tested (2026)

By The Automated Shop team · Updated November 22, 2026 · 14 min read

Some links below are affiliate links. If you buy through them we may earn a commission at no extra cost to you. It doesn't change our test results. How we make money.

Tested November 22, 2026 on n8n Community Edition 2.48.7, the npm latest release that day, self-hosted on our own test server with the default SQLite database. We ran three n8n instances: one with no proxy setting, one with N8N_PROXY_HOPS=1 and one with N8N_PROXY_HOPS=2, plus a small reverse proxy in front of each that adds the caller's address to X-Forwarded-For, the same way nginx's $proxy_add_x_forwarded_for does. "Office" and "stranger" callers were separate local IP addresses (127.0.0.2 and 127.0.0.3). In total we sent about 4,250 requests with curl and Python. Behavior is checked against n8n's Webhook node docs and Webhook credentials docs. We couldn't test n8n Cloud, because our trial has ended.

An n8n webhook URL is a public address. Anyone who has it can start your workflow: a bot that finds it in your website's code, a former contractor, someone who saw it in a screenshot. If that workflow adds a lead to your CRM, emails a customer or marks an invoice paid, a stranger can make it do that.

We built the same lead-intake webhook with every protection n8n offers, then sent it right, wrong and forged requests.

Short version:

  • If you control what calls the webhook (your website, a script, Make or Zapier), use Header Auth with a long random value. It blocked 2,000 wrong guesses out of 2,000, and none of them created an execution. But n8n saves the secret in plain text in every successful execution, so anyone who can see your executions can copy it.
  • If an app signs its webhooks (GitHub, Shopify, Stripe, most payment tools), check the signature against the raw body. The common shortcut, hashing JSON.stringify($json.body), rejected 35 of 45 genuine requests in our test: it only worked for 2 of 9 everyday JSON formats. Turning on Raw Body and hashing the file instead accepted 45 of 45 and still rejected every tampered request.
  • Treat the IP allowlist as a second lock, never the only one. Behind a proxy, it blocked our allowed "office" address until we set N8N_PROXY_HOPS. With N8N_PROXY_HOPS set higher than the real number of proxies, a stranger got in by sending a fake X-Forwarded-For header.
  • A valid signed request can be replayed. We sent the same signed request 10 times and got 10 executions. Skip event IDs you've already handled.

If a stranger starting your workflow sounds unlikely, look at what it costs: an open webhook ran 2,000 junk requests as 2,000 executions in 23 seconds. On n8n Cloud Starter, that would be 80% of the month's 2,500 executions.

Test 1: what each built-in option blocks

The Webhook node's Authentication setting has Basic Auth, Header Auth, JWT Auth and n8n User Auth. We tested the first three, plus no authentication and the node's newer Only Run If option used as a home-made token check. Each test request was a small JSON lead. "Executions" is how many runs n8n created.

Setup Request Response Executions
No authentication anything 200 "Workflow was started" 1
Header Auth (X-Webhook-Secret) no header, or wrong value 403 "Authorization data is wrong!" 0
Header Auth right value (header name in any case) 200 1
Basic Auth no login 401 "Authorization is required!" 0
Basic Auth wrong password 401 "Authentication data is wrong!" 0
JWT Auth (HS256) no token 401 "No token provided" 0
JWT Auth unsigned token (alg: none) 403 "jwt signature is required" 0
JWT Auth signed with the wrong secret 403 "invalid signature" 0
JWT Auth token expired an hour ago 403 "jwt expired" 0
JWT Auth valid token, with or without an expiry 200 1
Only Run If, ?token= in the URL missing or wrong token 200 "Webhook call received" 0

All three built-in methods did what they should. The rejections came back in about 0.01 seconds and created no execution, so they don't fill your execution list. Executions are what n8n Cloud bills, though we couldn't confirm the count on Cloud itself.

n8n Webhook node parameters: HTTP Method POST, Path header-lead, Authentication Header Auth, Credential for Header Auth set to Lead form header secret, Respond Immediately
Header Auth takes two fields, set once in a credential: the header name and the value.

Only Run If rejects quietly: a wrong token gets a normal-looking 200 and no run. That's handy against scanners, but your real sender gets a 200 too when its token is wrong, so a typo looks like success. n8n's docs warn that if the expression fails to evaluate, the request is let through. On 2.48.7 we couldn't make that happen. We tried 13 broken cases, including reading a header that wasn't sent and parsing text that wasn't JSON. Ten returned 200 with no run. The other three were expressions that couldn't run at all: a syntax error, a reference to a node that doesn't exist, and $env (which n8n 2.x blocks by default). Those returned a 500 error with an internal stack trace to every caller. We sent the right secret to the $env version, and it still got the 500.

Nobody slows down a guesser

We sent 2,000 wrong Header Auth values, 20 at a time. n8n answered all 2,000 with 403 in 9.5 seconds, about 211 guesses a second. Nothing was rate-limited, and the right value still worked straight afterwards.

That's fine for a 32-character random value: there are more possible values than anyone could try. It's not fine for something short. At the rate we measured, a six-digit number would take about 79 minutes to run through every option. Generate the value with a password manager and make it long.

Test 2: your secret is saved in every execution

This one surprised us. After a successful Header Auth request, we opened the execution. The secret was right there in the Webhook node's output, under headers:

n8n execution output JSON for the Webhook node: headers include host, user-agent curl/8.14.1, content-type application/json, and x-webhook-secret f6dfda7daf3cc6e7fadf02fd0ced5a6e in plain text, followed by the body with name Test Lead and email lead@example.com
A successful Header Auth run. The x-webhook-secret line is the secret itself (from our throwaway test instance).

We checked the stored execution data for each method:

Method What ends up in the saved execution
Header Auth the secret, in plain text
Basic Auth the Authorization header, which is the username and password in base64 (anyone can decode it)
Query token (Only Run If) the token, under query
JWT Auth the token. With a short expiry, it's useless a few minutes later.
Signature check (Test 3) the signature. It only matches that one request body.

n8n's code marks the headers it used to check a login so they can be hidden, but in 2.48.7 the Webhook node's saved output still showed them in our tests. So the secret is visible to anyone who can open your executions, and it goes wherever your workflow sends the whole incoming item: a "log every lead" Google Sheet, a Slack message, a CRM note. Self-hosted n8n keeps executions for 14 days or 10,000 runs by default, so it's also in your database backups.

What we'd do about it:

  • Don't pass the raw webhook item on. Map only the body fields you need (name, email, message) into the next step. Never map headers.
  • For a webhook that only needs to work, not to be debugged, set Workflow Settings → Save successful production executions to "Do not save". We sent 5 good requests to a workflow set that way, and 0 executions were stored. Failed runs are covered by a separate setting.
  • If you can make the sender do it, prefer a signature or a short-lived JWT. A leaked copy of either is close to useless. A leaked header secret works until you change it.
  • Change the secret when someone with n8n access leaves. Header Auth makes that a two-place change: the credential in n8n and the header in the sender.

Test 3: checking a signed webhook

Payment and e-commerce apps don't let you add your own header. They sign each request instead: they compute an HMAC-SHA256 of the request body with a secret you both know and send the result in a header. GitHub uses X-Hub-Signature-256 (GitHub docs), Shopify uses X-Shopify-Hmac-SHA256 (Shopify docs). Your workflow computes the same HMAC and compares.

n8n's Crypto node does HMACs without code, and the obvious way to feed it the body is an expression: {{ JSON.stringify($json.body) }}. We built that, and a second version with Raw Body turned on in the Webhook node and the Crypto node set to Binary File. Then we signed and sent 5 requests in each of 9 formats that real senders produce:

Body format the sender used JSON.stringify version Raw body version
Compact JSON, plain ASCII (typical of JavaScript senders) 5 of 5 accepted 5 of 5
Spaces after : and , (Python's default) 0 of 5 5 of 5
Pretty-printed, 2-space indent 0 of 5 5 of 5
Escaped slashes, https:\/\/ (PHP's default) 0 of 5 5 of 5
Accented name written as \u00e9 0 of 5 5 of 5
Accented name as plain UTF-8 5 of 5 5 of 5
A price written 10.50 0 of 5 5 of 5
A 19-digit numeric ID 0 of 5 5 of 5
Form-encoded body 0 of 5 5 of 5
Body changed after signing (tampered) rejected 5 of 5 rejected 5 of 5
No signature header rejected 5 of 5 rejected 5 of 5

The shortcut fails because the signature covers the exact bytes that were sent, and JSON.stringify rebuilds the body its own way. Here's one of the rejected requests. We sent 58 bytes with spaces after each colon and comma. The Crypto node hashed a 53-byte compact copy, so the two signatures don't match:

n8n Crypto node in an execution: Action Hmac, Binary File off, Type SHA256, Value expression JSON.stringify of the body resolving to the compact string id evt_1042, type invoice.paid, amount 4900. Output shows header content-length 58, x-signature 0544a443... and expected_signature 5ebd56fe..., which differ
The JSON.stringify shortcut: the sender's signature (x-signature) and n8n's (expected_signature) don't match, though the request is genuine.

The 19-digit ID shows a second problem: n8n stored 9007199254740993 as 9007199254740992. JavaScript numbers can't hold that many digits, so if a sender uses long numeric IDs, read them from the raw body or ask for them as text.

The fix is two switches:

n8n Webhook node: Respond set to Using Respond to Webhook Node, and under Options, Raw Body switched on
On the Webhook node: Add option → Raw Body. Respond is set to "Using 'Respond to Webhook' Node" so a bad signature gets a 401.
n8n Crypto node parameters: Credential for Crypto Payment app signing secret, Action Hmac, Binary File on, Binary Property Name data, Type SHA256, Property Name expected_signature, Encoding HEX
On the Crypto node: Binary File on, property data. The signing secret lives in a Crypto credential, so it isn't in the workflow file.

Don't reach for a Code node with require('crypto') instead: on 2.48.7 it failed with "Module 'crypto' is disallowed". Self-hosted, you can allow it with NODE_FUNCTION_ALLOW_BUILTIN=crypto; the Crypto node needs no change.

We checked the finished template against two published formats. With GitHub's own test values from its docs (secret "It's a Secret to Everybody", body "Hello, World!"), it accepted the request; with one character changed, it returned 401. With a Shopify-style base64 signature on a pretty-printed order, it accepted the right secret and rejected the wrong one. Accepted requests took a median of 22 milliseconds to answer.

Two limits. Stripe signs the timestamp, a dot, then the body (Stripe docs), and the Crypto node can't put the timestamp in front of the raw file; you need a Code node with crypto allowed. We didn't build that today. And the If node compares the two signatures with an ordinary equals, not the constant-time comparison GitHub's docs recommend. Over the internet that's a small risk next to having no check at all, but it's there.

Replays still get through

A signature proves the sender made the request. It doesn't prove it's new. We sent one genuine signed request 10 times, and the workflow accepted and ran all 10. Anyone who captures a request, or a sender retrying after a timeout, can trigger the same action again. Shopify's docs say to expect occasional duplicates and to skip repeated delivery IDs.

Store each event ID and skip ones you've seen. Our n8n Data Tables test shows which way of doing that held up when copies arrived at the same moment.

Test 4: the IP allowlist and your proxy

The Webhook node's IP(s) Allowlist option only accepts requests from addresses you list. We allowed one "office" address and tried three callers against five setups:

n8n Webhook node options: IP(s) Allowlist set to 127.0.0.2
The allowlist is a comma-separated list. Addresses outside it get 403 "IP is not allowed to access the webhook!"
Setup Office (allowed) Stranger Stranger with a fake X-Forwarded-For: <office IP>
n8n reached directly, N8N_PROXY_HOPS not set 200 403 403
Behind one proxy, N8N_PROXY_HOPS not set 403 403 403
Behind one proxy, not set, proxy's own IP added to the allowlist 200 200 200
Behind one proxy, N8N_PROXY_HOPS=1 200 403 403
Behind one proxy, N8N_PROXY_HOPS=2 (one too many) 200 403 200
Reached directly, but N8N_PROXY_HOPS=1 left set 200 403 200

If your self-hosted n8n sits behind a proxy (nginx, Caddy, Traefik, Cloudflare or a hosting platform's load balancer), this matters. Without N8N_PROXY_HOPS, n8n sees every request as coming from the proxy, so your allowlist blocks everyone. The tempting fix, adding the proxy's address, lets everyone in. n8n's docs give the right fix: set N8N_PROXY_HOPS to the number of proxies in front of n8n.

Set it exactly. With one hop too many, or with the setting left on after you remove the proxy, n8n believed the fake header and let the stranger in. Count every proxy that adds to X-Forwarded-For, which can include Cloudflare, and test with a request from an address that isn't on the list.

Even set correctly, an allowlist only works when the sender publishes fixed addresses (Stripe does, per its docs). Many services don't, and a cloud tool's addresses can be shared by its other customers. Use it alongside a secret or a signature.

What we'd do

  1. Pick the method by sender. Your own website, script, Make or Zapier: Header Auth with a 32+ character random value. An app that signs its webhooks: the raw-body signature check from the template on this page. A sender that can create tokens: JWT with an expiry of a few minutes.
  2. Map only body fields out of the Webhook node. The headers carry your secret.
  3. Add an event-ID check before anything that sends money, emails or messages.
  4. Behind a proxy, set N8N_PROXY_HOPS to the exact number of proxies before using the IP allowlist.
  5. Add an error workflow so a webhook that starts failing tells you.

Taking leads from your own website? Our n8n quote request form test covers what the Form Trigger does and doesn't check, including its "Ignore Bots" option.

Set up the template

  1. Download the template from the box on this page and import it into n8n (open a new workflow and paste the file's contents onto the canvas).
  2. Open HMAC of raw body, create a Crypto credential and paste the signing secret from the sending app into Hmac Secret.
  3. Open Signature matches? and change x-signature to the header your sender uses, in lower case, for example x-hub-signature-256 for GitHub. The template already strips a leading sha256=.
  4. For Shopify and other apps that send base64 signatures, set the Crypto node's Encoding to BASE64 and change the header to x-shopify-hmac-sha256.
  5. Replace Handle the event here with your steps, and publish. Send one real test event from the app and check that it gets a 200.
n8n canvas: Webhook, then HMAC of raw body, then Signature matches? If node. True goes to Accept (200), Parse event, Handle the event here. False goes to Reject (401)
The template. A bad signature gets a 401 and never reaches your steps.

On n8n Cloud, every accepted request is one execution, and rejected Header Auth, Basic Auth and JWT requests didn't create one in our tests (how n8n counts executions). Note that a request rejected by the signature check does run the workflow, so it counts. Starter was $24 a month billed monthly, or $20 a month billed annually, for 2,500 executions on the pricing page when we checked on November 22, 2026. Pro was $60, or $50 billed annually, for 10,000. We haven't tested whether Cloud adds its own rate limiting in front of webhooks. Try n8n Cloud (affiliate link). The trial needs no card. Running it yourself instead? See n8n self-hosted vs Cloud.

FAQ

Is an n8n webhook URL secret? Not really. The default path is random and hard to guess, but the URL can end up in website code, browser history, logs and screenshots. Add authentication to any webhook that does something.

Which n8n webhook authentication should I use? Header Auth when you control the sender, a raw-body signature check when the sending app signs its requests, and JWT when the sender can create short-lived tokens. Basic Auth works too, but it's saved in executions just like Header Auth.

Do rejected webhook requests count as executions? In our tests, requests rejected by Header Auth, Basic Auth, JWT Auth, the IP allowlist or Only Run If created no execution. Requests rejected by a signature check inside the workflow did, because the workflow had to run to check them.

Why does my n8n HMAC signature never match? Almost always because you're hashing $json.body instead of the raw body. Turn on Raw Body in the Webhook node and set the Crypto node to Binary File. Check the encoding (hex or base64) and any sha256= prefix too.

Does the n8n IP allowlist work behind nginx or Cloudflare? Only with N8N_PROXY_HOPS set to the exact number of proxies. Without it, every request looks like it came from the proxy.

Does The Automated Shop earn a commission from n8n? Yes, if you sign up through our "Try n8n Cloud" link, which is an affiliate link. It costs you nothing extra and doesn't change our test results. Citation links to n8n's docs and pricing page carry no referral tag. See our affiliate disclosure.

Weekly dispatch

One automation you can steal, every week

One working automation per email, with the spec and what it costs to run. Unsubscribe from any email.