Summary
A flaw in n8n's JavaScript Task Runner sandbox allows authenticated workflow authors to inject and execute arbitrary code on the Task Runner host.
When Task Runners are enabled, crafted workflow logic can escape the sandbox boundary, potentially leading to full host compromise in internal-runner mode or cross-workflow impact in external-runner deployments.
Affected context
This vulnerability affects n8n instances where:
- Task Runners are enabled (
N8N_RUNNERS_ENABLED=true), and - Users are granted permissions to create or modify workflows that include JavaScript executions.
The issue resides in the JavaScript Task Runner sandboxing layer, where the isolation boundaries are not fully enforced. In environments using the internal Task Runner (default mode), the Task Runner shares the same host as the core n8n process, increasing the impact of a sandbox escape. In external Task Runner mode, the impact is more contained to the runner environment but may still affect other workflows sharing the same runner.
Exploit preconditions
- Attack surface: n8n workflow editing interface and APIs that allow creation or modification of workflows containing JavaScript.
- Required access: Authenticated account with permissions to create or edit workflows that run in the JavaScript Task Runner.
- Configuration requirements: Task Runners must be enabled (
N8N_RUNNERS_ENABLED=true); risk profile depends onN8N_RUNNERS_MODE(internal vs external). - Trigger point: Execution of a malicious or specially crafted workflow step that leverages the JavaScript Task Runner sandbox.
- Why exploitation is possible: The sandbox implementation fails to fully restrict access to the underlying execution environment, allowing controlled JavaScript to break isolation and perform operations beyond the intended scope.
Why this happens
The underlying issue is an incomplete sandboxing model for server-side JavaScript execution within the Task Runner component.
This maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), where user-controlled script content is executed in an environment that has broader privileges than intended.
Instead of being strictly confined, the JavaScript runtime can access or influence resources outside its sandbox boundary, such as the host filesystem, process environment, or other workflows sharing the same Task Runner.
Conceptually, the design trusts workflow-level JavaScript more than it should, failing to enforce strict separation between user-provided code and the privileged execution context that runs it.
Potential impact
- Execution of arbitrary code on the n8n host when using internal Task Runners.
- Reading, modifying, or deleting data managed by n8n, including workflow definitions and credentials accessible to the compromised process.
- Lateral movement to other services or infrastructure reachable from the n8n host (e.g., databases, APIs, internal systems).
- Interference with or data exfiltration from other workflows executed on the same external Task Runner.
- Denial of service by crashing the Task Runner or exhausting CPU, memory, or disk resources.
General mitigation guidance
Effective mitigation focuses on hardening sandbox boundaries and minimizing trust in workflow-level code:
- Treat all workflow-authored JavaScript as untrusted, even from authenticated users, and enforce strict isolation between the script runtime and the host environment.
- Use process or container isolation for Task Runners so that each workflow (or tenant) executes in a dedicated, least-privileged environment with limited filesystem and network access.
- Restrict which APIs, globals, and modules are exposed to the sandbox, ensuring there is no direct path to host-level capabilities or sensitive secrets.
- Apply the principle of least privilege to Task Runner processes: run under non-privileged accounts, with minimal OS permissions and constrained network egress.
- Limit workflow creation and editing rights to highly trusted users, and treat "can execute JavaScript" as an elevated permission akin to code execution on infrastructure.
- Where possible, favor declarative or configuration-based workflow steps over arbitrary JavaScript logic, reducing the attack surface of dynamic code execution.
How teams detect issues like this
Organizations can use a combination of code-centric and behavior-centric approaches to detect similar issues:
- Static analysis and code review: Examine Task Runner and sandbox implementation for:
- Direct or indirect exposure of powerful host APIs to sandboxed code.
- Use of unsafe evaluation constructs (
eval-like behaviors, dynamicFunctioncreation) in privileged contexts. - Insufficient validation or scoping of objects passed into the sandbox.
- Configuration and permission reviews: Regularly review:
- Which users and roles can create or modify workflows containing custom JavaScript.
- Where Task Runners are deployed (internal vs external) and what privileges those hosts have.
- Runtime monitoring: Monitor Task Runner hosts for:
- Unexpected filesystem access patterns from Task Runner processes.
- Outbound network connections to unusual internal or external destinations.
- Anomalous process trees or shell invocations originating from Task Runner processes.
- Automated policy enforcement: Use CI/CD and security tooling to:
- Flag changes that modify sandbox boundary code, runner configuration, or privileges.
- Enforce policies requiring additional review when expanding the capabilities exposed to workflow-level JavaScript.

