A self-hosted n8n instance holds credentials for email, CRM, databases, cloud accounts and AI APIs. n8n 3.x improves several defaults, but the instance is still yours to secure. This guide covers the controls that matter most.
A self-hosted n8n instance is not a simple cron runner. It holds credentials for email, CRM, databases, cloud accounts, and AI APIs. It listens on webhooks. It runs code. It can call internal services that have no other public path.
That makes n8n security a hosting problem, not just a workflow-design problem. An attacker who reaches the instance does not need to steal every password. They can run a workflow that uses the credentials the instance already has.
Consider an agency with 80 client workflows. The instance holds API keys for 30 SaaS tools, a shared mailbox, two databases, and an AI provider. One editor account is phished. The attacker does not need the keys; they can create a workflow that uses them. That is the n8n security problem in one sentence.
n8n 3.x improves several defaults. It also changes the deployment model and adds agents and MCP as new paths into the same credential store. The controls below are the ones that matter most.
Why n8n is a high-value target
The average n8n instance is a concentrator. One workflow may connect a support inbox, a CRM, a Postgres database, and an LLM API. Another may post to Slack, update a spreadsheet, and call a payment API. The credentials are stored so the workflows can run without a person present.
That convenience is the risk. A compromised editor account can create a workflow that uses the instance’s credentials, even if the attacker never sees the secret. A public webhook can start a workflow. A Code node can run JavaScript. A community node can run with the instance’s access.
The blast radius is not the n8n dashboard. It is every system the instance can reach.
The first rule of n8n security is to treat the instance as a credential store with a workflow engine attached. The workflow is the interface; the credentials are the asset.
The 3.x defaults that changed
n8n 3.0 changed several security defaults. The changes are improvements, but they can break workflows that relied on the old behavior.
Encryption key rotation is on by default. On first startup, n8n generates a data encryption key and stores it in the database. Older versions cannot read the new format.
Slack credentials require a signing secret. A Slack trigger without one will fail.
The SSRF block list is larger. Workflows that call internal addresses may be blocked unless you allow them explicitly.
Unverified community packages are off by default. A workflow that depends on one will fail until an administrator enables it or replaces the node.
Docker is the supported self-host path.
npmandnpxinstalls are no longer supported.
Two of these are security controls. Two are operational changes that affect security. Treat all four as part of the upgrade review.
Credentials: the encryption key is the crown jewel
n8n encrypts stored credentials with an instance key, N8N_ENCRYPTION_KEY. In 3.x, a second data encryption key protects the credential data, and that key can be rotated. The instance key protects the data key.
The practical rules are simple:
Set the instance key explicitly. Do not let n8n generate it into a volume you might replace. Store it in a secret manager, not in Git.
Use the same key on every instance. Main, workers, and webhook processors must share it. A mismatched key means credentials cannot be decrypted.
Back up the database and the key together. A database backup without the key is not a credential backup. A key without the database is not useful either.
Test the restore. A backup you have never restored is a hope.
Rotate deliberately. n8n’s docs warn that once data is written with a data encryption key, older versions cannot read it. Back up before enabling rotation or upgrading to 3.0.
Store the instance key in a secret manager, not in the Compose file. Restrict who can read it. When you rotate the data key, do it in staging first, and keep the old database backup until the new key has been exercised in production.
The key is also the reason a full instance compromise is severe. If an attacker gets the key and the database, the credentials are readable. If they get only the application, they can still use the credentials through workflows. The difference is time and access, not safety.
Webhooks and network exposure
Webhooks are public by design. A production webhook URL can start a workflow from anywhere unless the workflow checks the caller. The n8n security surface starts here, at the paths you expose to the internet.
Put the instance behind a reverse proxy that terminates TLS. Restrict the public surface to the webhook paths that need to be public. Keep the editor and the API on a private network or behind an identity-aware proxy.
For each webhook, decide:
Authentication. Use header auth, basic auth, or JWT where the caller supports it. A secret URL is not authentication.
IP allow-list. If the caller has fixed addresses, restrict them.
CORS. Do not leave a browser-facing webhook open to every origin.
Payload validation. Check the shape and size before the workflow acts on it.
Idempotency. A duplicate webhook should not create a duplicate order or refund.
n8n’s security documentation recommends a reverse proxy for TLS, encryption at rest, a security audit, and careful handling of community nodes. It also recommends disabling nodes you do not use, such as Execute Command or SSH, and preventing the Code node from importing external modules.
MCP and agent tool permissions
Agents and MCP add a new path to the same credentials. An agent can call a workflow, an MCP server, or a tool. If the tool writes to a CRM or sends email, the agent can do that too.
n8n’s Agents feature is in preview. It supports tools, skills, sub-agents, knowledge files, and memory. Sensitive tools can require approval before the agent runs them, and each session’s tool calls, inputs, and outputs can be reviewed.
Use those controls:
Mark write tools for approval. A read-only lookup can run unattended. A refund, deletion, or external message should not.
Scope the agent’s tools. Give it the workflows and MCP servers its job needs, not the whole instance.
Review sessions. An agent’s reasoning trace is not an audit log. Check the tool calls and the results.
Watch the preview limits. Queue mode is not supported for agents yet, and knowledge bases are preview. Do not build a production dependency on a preview feature without a fallback.
Treat MCP servers as third-party code. A server can return malicious content, call other tools, or hold its own credentials. Vet it like a community node.
The agent is not the security boundary. The runtime and the tool permissions are.
Docker and task-runner hardening
The n8n 3.x deployment is Docker-based. That gives you a clean boundary, but only if you use it.
Start with the host:
Run a 64-bit Linux host with a minimal attack surface.
Put n8n behind a reverse proxy or load balancer.
Use a firewall that allows only the ports that need to be public.
Keep PostgreSQL and Redis on a private network.
Mount a persistent volume for the n8n data directory.
Back up the volume and the database on a schedule.
Then harden the Code node. n8n’s task runners execute Code node JavaScript. The docs recommend external task runners as sidecars, the distroless image, running as the unprivileged nobody user (UID 65532), a read-only root filesystem, and an AppArmor profile that denies access to /proc/*/environ and /proc/*/mounts.
Those controls matter because a Code node is arbitrary JavaScript. A workflow editor who can write code can reach the task runner’s environment. The runner should not be able to read the host’s secrets or modify its filesystem.
A security checklist
Use this as a review, not a one-time setup. A useful n8n security review follows the same order every time, so a new workflow cannot skip a control.
Inventory the instance. Version, database, queue mode, binary data mode, community packages, and public webhooks.
Set and store the encryption key. Use a secret manager. Keep it out of Git and out of the workflow data.
Put TLS in front. Terminate at a reverse proxy. Redirect HTTP to HTTPS.
Restrict the public surface. Only the webhook paths that need to be public. Editor and API on a private network or identity-aware proxy.
Authenticate webhooks. Header, basic, or JWT auth. Add IP allow-lists where possible.
Disable unused nodes. Execute Command, SSH, and other high-risk nodes if the team does not need them.
Turn off unverified community packages. Enable only the packages you have reviewed.
Run the security audit. n8n’s audit checks credentials, SQL nodes, filesystem nodes, risky nodes, and instance settings.
Harden task runners. External sidecars, distroless, non-root, read-only root, AppArmor.
Review agent tools. Approvals for writes, scoped tools, session review.
Redact execution data. Do not store secrets or customer data in execution logs longer than needed.
Back up and test restore. Database, data volume, and encryption key.
What to monitor
Security is not finished at deployment. Watch the instance.
Failed logins and new users. A new admin is a change worth investigating.
New or changed credentials. Credential creation is a privileged action.
Webhook traffic. Spikes, unusual source addresses, and malformed payloads.
Execution failures. A sudden rise can be an attack, a broken dependency, or a bad deploy.
Outbound connections. n8n can call internal and external services. Alert on new destinations.
Version and advisory status. n8n ships often. Track security releases and upgrade on a schedule.
Queue depth and worker health. A stuck queue can hide a failed workflow.
The monitoring stack should cover the host, the container, the database, and the application. A dashboard that only shows CPU misses the workflow that is sending customer data to the wrong endpoint.
Alert on new admin users, changes to the encryption key, new webhook paths, and outbound connections to addresses the instance has not used before. Those four signals catch many of the paths from a workflow mistake to an incident. Review the n8n audit output weekly; it is a starting point, not a certification. The instance is only as secure as its least-reviewed workflow.
A self-hosted n8n instance gives you control and responsibility. A managed service moves the patching and some of the hardening to the vendor, but you still own the workflows, the credentials, and the data.
Neither option removes the need for least privilege. The instance will always hold secrets. The goal is to make sure it holds only the secrets it needs, that the people who can use them are known, and that a failure is visible before it becomes a breach.
Start with the encryption key, the public surface, and the task runner. Those three controls cover the most common paths from a workflow mistake to a real incident.
Harden the automation host before it holds more keys
SysopHost provides n8n hosting, Docker infrastructure, and managed cybersecurity for teams that need a monitored automation runtime.
Review Managed SecurityFrequently Asked Questions
Comments
No comments yet. Be the first to comment!
Arjun Mehta