Summary
A critical sandbox escape in n8n expression evaluation allows an authenticated workflow author to bypass restrictions using specially crafted arrow-function expressions. Under affected versions and sufficient workflow permissions, this may execute system commands on the host running n8n.
Affected context
The vulnerability occurs in n8n deployments that evaluate user-controlled workflow expressions inside the expression sandbox. It becomes risky when an authenticated user can create or modify workflows and the affected expression evaluator processes arrow-function bodies without adequately restricting their behavior.
Exploit preconditions
- Attack surface: n8n workflow expression evaluation
- Required access: An authenticated account with permission to create or modify workflows
- Trigger point: Evaluation of a crafted expression containing an arrow-function body
- Why exploitation is possible: The expression sandbox can be bypassed, allowing expression logic to reach host-level system command execution
Why this happens
The underlying issue is insufficient isolation of executable expression logic within n8n's sandbox. Certain arrow-function bodies are handled in a way that permits sandbox restrictions to be bypassed, allowing attacker-controlled expressions to invoke capabilities outside the intended evaluation model. This maps to CWE-94: Improper Control of Generation of Code, because input-controlled expression content can be interpreted as executable code beyond the permitted boundaries.
Potential impact
- An attacker may execute system commands on the n8n host
- The attacker could access or alter workflow data and credentials available to the process
- The n8n service may be compromised or disrupted
- Connected systems and downstream automation could be affected
- A compromised host could support lateral movement, depending on runtime privileges and network access
General mitigation guidance
Mitigation focuses on ensuring that expression evaluation cannot cross the intended trust boundary.
Common defensive patterns include:
- Use a release containing the vendor's security fix rather than relying on sandbox restrictions alone
- Replace general-purpose expression execution with narrowly scoped, allowlisted operations
- Reject or safely transform unsupported function constructs before evaluation
- Limit workflow-authoring permissions to trusted users and groups
- Run n8n with least-privilege operating-system and network permissions
- Keep secrets and sensitive host capabilities outside the workflow execution context where possible
- Apply container, filesystem, and network isolation to reduce the consequences of a sandbox failure
How teams detect issues like this
Organizations can look for this issue through:
- Static analysis and code review of expression evaluators, sandbox boundaries, and dynamic code-generation paths
- Tests covering arrow functions, nested expressions, generated functions, and attempts to access host APIs
- Audit logs for unexpected workflow creation or modification by authenticated users
- Monitoring n8n processes for unusual child-process creation, shell invocation, or unexpected outbound connections
- Policy enforcement that restricts workflow editing and flags high-risk expression constructs
- Automated security review tools that identify code-generation and sandbox-escape patterns

