How to Fix Unauthenticated n8n Webhooks & Execute Command RCE (N8N001–N8N006)
A single public n8n Webhook with authentication: "none" chained to an Execute Command
node turns a workflow into unauthenticated remote code execution. Audit and harden your *.n8n.json
locally below with 0 bytes uploaded.
100% client-side AST engine · 0 bytes sent · One-time Polar.sh license (no subscription) unlocks all 72 rules + CI SARIF 2.1.0.
Vulnerable vs. Hardened n8n Workflow JSON (Before & After)
Compare an exposed webhook + shell injection chain against a hardened workflow using headerAuth,
typed HTTP API calls, strict TLS validation, credential store references, and an explicit errorWorkflow.
{
"settings": { "saveDataErrorExecution": "none" },
"nodes": [
{
"type": "n8n-nodes-base.webhook",
"parameters": {
"path": "customer-sync",
"authentication": "none",
"options": { "allowedOrigins": "*" }
}
},
{
"type": "n8n-nodes-base.executeCommand",
"parameters": {
"command": "=/usr/local/bin/sync.sh {{ $json.customerId }}"
}
},
{
"type": "n8n-nodes-base.httpRequest",
"parameters": {
"url": "http://billing.internal/charge",
"allowUnauthorizedCerts": true,
"headerParameters": {
"parameters": [
{ "name": "Authorization", "value": "Bearer demo_hardcoded_billing_token_8a7b6c5d" }
]
}
}
}
]
}
{
"settings": {
"errorWorkflow": "wf-ops-alerting-01",
"executionTimeout": 120,
"saveDataErrorExecution": "all"
},
"nodes": [
{
"type": "n8n-nodes-base.webhook",
"parameters": {
"path": "customer-sync",
"authentication": "headerAuth",
"options": { "allowedOrigins": "https://app.example.com" }
},
"credentials": { "httpHeaderAuth": { "id": "cred-wh-1", "name": "Webhook Secret" } }
},
{
"type": "n8n-nodes-base.httpRequest",
"retryOnFail": true,
"parameters": {
"url": "https://billing.internal.example/api/charge",
"authentication": "predefinedCredentialType",
"allowUnauthorizedCerts": false,
"options": { "timeout": 10000 }
}
}
]
}
Audit Your *.n8n.json Locally (All 20 n8n Rules)
100% in-browser · 0 bytes sent · < 10 ms
Paste any exported n8n workflow JSON below to detect unauthenticated webhooks, Execute Command RCE, hardcoded Bearer tokens, TLS bypasses, and missing reliability guardrails locally in your browser.
stackguard-cli, SARIF 2.1.0, and SHA-256 sealed SOC 2 / ISO 27001 / DORA compliance reports.
Exact Remediation Reference: Rules N8N001–N8N006
| Rule ID | Severity | Vulnerability & CWE | Exact Fix |
|---|---|---|---|
N8N001 |
CRITICAL |
Unauthenticated n8n Webhook trigger
|
Set authentication to headerAuth, jwtAuth, or basicAuth backed by n8n Credentials, plus HMAC verification for third-party webhooks. |
N8N002 |
CRITICAL |
Command injection in n8n Execute Command node
|
Remove {{ $json.* }} interpolation from shell strings. Prefer native API/HTTP nodes or validate inputs strictly against an alphanumeric regex. |
N8N003 |
CRITICAL |
Dangerous dynamic execution in n8n Code/Function node
|
Eliminate eval(), new Function(), and child_process imports in Code nodes; set NODE_FUNCTION_ALLOW_BUILTIN="" in Docker env. |
N8N004 |
HIGH |
TLS certificate verification disabled (allowUnauthorizedCerts)
|
Set allowUnauthorizedCerts: false and mount your internal CA certificate via NODE_EXTRA_CA_CERTS instead of disabling TLS validation. |
N8N005 |
CRITICAL |
Hardcoded API key or Bearer token in n8n workflow JSON
|
Move all API keys and Bearer tokens into n8n encrypted Credentials (protected by N8N_ENCRYPTION_KEY) so exports never expose plaintext secrets. |
N8N006 |
MEDIUM |
Missing errorWorkflow in n8n workflow settings
|
Configure a dedicated settings.errorWorkflow that sends failed execution alerts to Slack, PagerDuty, or email alongside executionTimeout. |
Frequently Asked Questions
How do I secure an n8n Webhook trigger without breaking third-party callers?
Use headerAuth or jwtAuth backed by n8n Credentials for internal callers, restrict allowedOrigins, and verify raw-body HMAC signatures for external webhooks (Stripe, Polar.sh, GitHub).
Why is interpolating {{ $json.* }} inside an n8n Execute Command node a critical RCE?
Execute Command invokes a shell; unvalidated JSON fields containing ;, &&, or backticks run arbitrary commands inside the n8n container and can dump N8N_ENCRYPTION_KEY and database credentials.
Does StackGuard upload my exported n8n workflow JSON or credentials?
No. Every check executes inside your browser tab via scanner-bundle.js with zero network calls during scanning.
Need a full self-hosted n8n production architecture?
Pair StackGuard with StackBlueprint for production-hardened Docker Compose, Caddy/Traefik, Postgres, Redis queue-mode, and worker architectures.