Summary
n8n's workflow expression evaluation system contains an input evaluation flaw that can lead to remote code execution when user-supplied expressions are executed in an overly-privileged runtime context.
Authenticated users who can configure workflows may craft expressions that escape the intended sandbox, allowing arbitrary code execution with the privileges of the n8n process and full compromise of the affected instance.
Affected context
This vulnerability arises in n8n instances where:
- Authenticated users are allowed to create or modify workflows that include dynamic expressions
- The expression engine evaluates user-supplied input in a context with access to powerful runtime objects (e.g., filesystem, OS, or process APIs)
- There is no strong sandbox or isolation boundary between expression evaluation and the underlying application runtime
The risk is heightened in multi-user or shared deployments where non-admin users can define or alter workflows.
Exploit preconditions
- Attack surface: Application-level, via the n8n UI or API endpoints used to create or update workflows and their expressions.
- Required access: Valid authenticated account with permissions to create, import, or modify workflows or nodes that support dynamic expressions.
- Trigger point: Execution of a crafted workflow or node where the malicious expression is evaluated at runtime (e.g., during workflow runs, test executions, or scheduled jobs).
- Why exploitation is possible: The expression evaluation mechanism interprets user-controlled input in a highly-privileged execution context without sufficient sandboxing, allowing access to underlying runtime capabilities instead of restricting evaluation to a safe, declarative subset.
Why this happens
The core issue reflects CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code, where user-controlled expressions are passed into an evaluator that executes them as code within the application runtime.
Instead of treating workflow expressions as strictly bounded, data-only templates, the engine exposes interpreter or language features that can be chained to reach process-level capabilities (such as reading files, executing commands, or manipulating runtime objects). This breaks the intended abstraction boundary between "workflow configuration" and "application internals," and turns configuration input into executable logic with access to the full privileges of the n8n process.
Potential impact
- Execution of arbitrary code with the privileges of the n8n process
- Unauthorized access to sensitive data stored or processed by n8n (credentials, secrets, execution logs, workflow definitions)
- Modification, deletion, or exfiltration of workflows and related configuration
- Lateral movement to connected systems and services through compromised credentials or integrations
- Abuse of the host system for further attacks, including installing backdoors, pivoting, or data destruction
General mitigation guidance
Effective mitigation generally centers on constraining expression evaluation and reducing the privileges of the execution environment:
- Prefer declarative, non-Turing-complete expression formats or template languages that cannot directly invoke runtime APIs or arbitrary code.
- If a scripting capability is needed, run it inside a strictly sandboxed interpreter that:
- Exposes only a minimal, whitelisted API surface tailored to workflow needs
- Blocks access to filesystem, process, network, and other OS-level capabilities by default
- Implement rigorous separation between configuration data and executable logic, ensuring that fields intended as data are never passed to dynamic code evaluators.
- Apply least-privilege principles to the n8n process and its integrations:
- Run the service under a restricted OS account with minimal filesystem and network permissions
- Limit access to secrets, environment variables, and administrative interfaces
- Introduce defense-in-depth controls such as role-based access control for workflow editing, strong authentication, and careful use of shared or multi-tenant instances.
How teams detect issues like this
Detection efforts can focus on both code-level and runtime behaviors:
- Static analysis and code review:
- Flag any use of dynamic evaluation constructs (e.g., generic "eval"-like APIs) in the expression engine or workflow processing code paths.
- Look for code paths where user-controlled workflow fields are passed into interpreters or template engines that allow arbitrary code execution.
- Verify that any evaluation mechanisms operate within a constrained and clearly defined sandbox, and that only a vetted subset of functions/objects is exposed.
- Configuration and policy enforcement:
- Establish coding guidelines prohibiting direct execution of user-supplied expressions in unrestricted runtime contexts.
- Enforce policies in CI/CD that block merges introducing new dynamic evaluation features without sandboxing and security review.
- Runtime monitoring:
- Monitor for anomalous workflow executions that perform unexpected filesystem access, command execution, or outbound network calls from the n8n process.
- Use logging and audit trails to detect suspicious expression content in workflow definitions and execution logs.
Automated security scanners, SAST tools, and policy-as-code frameworks can be integrated into the development pipeline to systematically detect dangerous evaluation patterns early.

