Task Runners: Running Code Nodes More Securely
n8n Task Runners execute Code nodes in isolation instead of the main process. Here is how internal and external mode work.
How to harden n8n: enable 2FA, set up SSRF protection, lock down risky nodes with NODES_EXCLUDE, and disable the Public API when it is unused.
Anyone running a self-hosted n8n instance bears full responsibility for securing it themselves, because n8n Cloud automatically handles part of this protection, while a self-managed server does not do so on its own. In the security configuration section of the official n8n documentation alone there are more than a dozen individual chapters, from two-factor authentication through SSRF protection to the Public API, that have not previously been bundled together in this form anywhere in German. The four most important levers for ongoing operation are: making 2FA available and requiring it, enabling SSRF protection, locking down risky nodes via NODES_EXCLUDE, and disabling the Public API when nobody needs it. As of: July 2026.
n8n enables the 2FA feature instance-wide via the environment variable N8N_MFA_ENABLED, which defaults to true. This allows individual users to set up two-factor authentication themselves in their personal account settings, but a central switch that enforces it for all accounts at once is not described in the core documentation. Important in practice: once a user has enabled 2FA, n8n ignores a later attempt to disable it via the environment variable according to the documentation, so the protection cannot be accidentally undone by a configuration change.
Server-Side Request Forgery means that a workflow node, such as the HTTP Request node, is misused to send requests to internal network resources, cloud metadata endpoints, or localhost services that should not actually be reachable from outside. n8n has offered its own protection mechanism for this since version 2.12.0, which can be enabled via N8N_SSRF_PROTECTION_ENABLED=true. When the protection is active, n8n checks outgoing HTTP requests from user-controlled nodes against configured allow and block lists, including redirect targets and DNS resolution, to prevent typical bypass tricks.
Not every node is suitable for every user group. The environment variable NODES_EXCLUDE lets you define a list of node types that are neither discoverable nor usable for any user of the instance. The value is passed as a JSON array of node identifiers, for example NODES_EXCLUDE with the content ["n8n-nodes-base.executeCommand", "n8n-nodes-base.readWriteFile"]. The documentation specifically names the Execute Command node and the Read/Write Files from Disk node as typical candidates for environments in which not all users are fully trusted, since both allow direct access to the host system.
The n8n Public REST API allows practically everything that can also be done through the interface to be controlled programmatically, that is, creating workflows, triggering executions, or managing credentials. This is exactly what makes it an additional attack surface when it remains active unused. Via N8N_PUBLIC_API_DISABLED=true you disable the Public API completely, and the documentation explicitly recommends this if nobody actually uses the API. Anyone who does need the API but does not want to show the interactive documentation interface publicly can additionally set N8N_PUBLIC_API_SWAGGERUI_DISABLED=true, which only disables the API playground, while the API itself remains reachable.
The four points named above are the ones with the greatest leverage for everyday operation, but they do not cover the full range. The n8n security documentation also covers, among other things, Single Sign-On, the requirement to verify new accounts by email, TLS encryption for the connection, the regular rotation of encryption keys, JWE decryption of OAuth 2.0 tokens, redacting execution data, securing task runners, and disabling telemetry. n8n additionally recommends regularly running a built-in security audit, which automatically checks many of these settings and lists open items. Anyone who does not want to maintain these settings themselves will find, as part of our n8n consulting support for setup and ongoing operation, where we also honestly point out where automation alone is not enough and organizational rules within the team remain necessary.
n8n enables the feature instance-wide via N8N_MFA_ENABLED, but the actual setup happens per user account in the personal settings. A central switch that immediately makes 2FA mandatory for all accounts is not described in the core documentation, so it remains your task to require the team organizationally to activate it.
No. SSRF protection works at the application level and checks outgoing requests from workflow nodes, thereby complementing network controls such as firewalls and security groups, but according to the documentation it explicitly does not replace them.
The documentation names the Execute Command node and the Read/Write Files from Disk node as typical candidates for NODES_EXCLUDE, because both allow direct access to the underlying host system. Which other nodes are risky depends on your specific user group.
Only if you control n8n programmatically, for example from your own scripts, other systems, or CI/CD pipelines. If the API is not actively used, the documentation recommends disabling it completely via N8N_PUBLIC_API_DISABLED.
Sources: n8n Security overview, Two-factor authentication, Enable SSRF protection, Blocking nodes, Disable the Public API
Founder of NordFlux. Spent four years automating processes at enterprise scale at Dräger, and now brings that depth to the mid-market — pragmatic and with full data sovereignty.
Certifications
n8n Task Runners execute Code nodes in isolation instead of the main process. Here is how internal and external mode work.
Switching from self-hosted to n8n Cloud: maintenance effort drops, but so does control. What does not automatically carry over with nodes and credentials.
Shopware 6 has no native n8n node. Here's how you connect orders, customers, and stock via the Admin API and HTTP Request Node.
2FA, SSRF protection and blocked nodes are only the beginning: a secure n8n instance needs ongoing care, updates and attention to every new attack surface. NordFlux runs n8n as a managed service and takes care of hardening, monitoring and updates for you. In an initial conversation we assess where your instance is exposed today.