/

CVE-2026-27495

Severity:

CRITICAL RISK

(9.9)

Code Injection in n8n Task Runner Sandbox

CVE-2026-27495

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution by Authenticated Users

Severity:

CRITICAL RISK

(9.9)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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 on N8N_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, dynamic Function creation) 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.

Sources

SourceLink
docs.n8n.iodocs.n8n.io/hosting/configuration/task-runners
github.comgithub.com/n8n-io/n8n/releases/tag/n8n@1.123.22
github.comgithub.com/n8n-io/n8n/releases/tag/n8n@2.10.1
github.comgithub.com/n8n-io/n8n/releases/tag/n8n@2.9.3
github.comgithub.com/n8n-io/n8n/security/advisories/GHSA-jjpj-p2wh-qf23

Frequently asked

questions

Exploitation is highly practical in environments where users with workflow-authoring permissions are not fully trusted. Because the attacker can control JavaScript executed by the Task Runner, a flawed sandbox can often be bypassed with crafted code, leading to host-level impact when internal runners are used.

No additional system or network-level access is required beyond an authenticated n8n account with permissions to create or modify workflows that run in the JavaScript Task Runner. The attack is carried out entirely through n8n's workflow interface or its APIs.

The safest pattern is to avoid running user-influenced code in a privileged context. If running user-authored JavaScript is required, it should execute in a strongly isolated environment (e.g., separate container or process with minimal privileges) with a narrow, carefully audited interface to host resources. The sandbox should expose only the minimal necessary capabilities, with clear boundaries between workflow code and infrastructure.

Prevention involves designing workflow execution as if it were running attacker-controlled code:

  • Use strong OS- or container-level isolation around any dynamic code execution component.
  • Keep sandbox APIs minimal and deny access by default to host capabilities.
  • Treat "can execute custom code" as a high-risk permission and restrict it to trusted operators.
  • Incorporate security review, static analysis, and targeted testing around sandbox and runner code whenever these components are modified.
Find out what's already
exploitable in your codebase.