Summary
n8n has an insufficiently isolated workflow expression evaluator that may let authenticated users escape its sandbox and execute code on the host. The risk arises when a user can create or modify workflows and trigger evaluation of a crafted expression.
Affected context
The issue occurs in n8n's workflow expression evaluation, where expressions are intended to run within a restricted sandbox. Deployments may be at risk when authenticated users have permission to create or modify workflows and those workflows are evaluated by the n8n host.
Exploit preconditions
- Attack surface: Workflow expression evaluation in n8n
- Required access: Authenticated access with permission to create or modify workflows
- Trigger point: Evaluation of an expression in a workflow
- Why exploitation is possible: Unexpected JavaScript property access can bypass the evaluator's isolation boundary and enable code execution
Why this happens
The underlying issue is insufficient isolation between workflow expressions and the host runtime. Expression evaluation exposes or permits access to unexpected JavaScript properties, allowing untrusted workflow logic to cross the sandbox boundary. This maps to CWE-94: Improper Control of Generation of Code, because attacker-influenced input can result in executable code running in the host context.
Potential impact
- An attacker could execute arbitrary code on the n8n host
- The host's data and runtime secrets may be exposed or altered
- The n8n service could be disrupted or used to access other systems, depending on its privileges and network access
General mitigation guidance
Defensive approaches focus on maintaining a robust boundary between user-authored expressions and the host runtime.
- Use expression evaluation designs that do not expose host objects or unsafe JavaScript properties
- Treat workflow definitions and expressions as untrusted, including those created by authenticated users
- Restrict workflow creation and modification to users who need those capabilities
- Run n8n with least-privilege permissions and limit access to sensitive files, credentials, and network resources
- Apply secure-by-default policies that constrain expression capabilities and reduce the impact of a sandbox escape
How teams detect issues like this
- Review expression evaluators for access to host objects, prototypes, constructors, or unexpected JavaScript properties
- Use static analysis and code review to identify dynamic evaluation and incomplete sandbox boundaries
- Monitor workflow changes and expression execution, especially for unexpected modifications or unusual host activity
- Enforce policies that limit who can create or modify workflows and what capabilities their expressions can access
- Automated code review tools may help flag risky dynamic evaluation patterns

