Summary
n8n's expression evaluation engine contained flaws that allowed crafted workflow expressions to be interpreted as executable system commands on the host.
An authenticated user with permissions to create or modify workflows could embed malicious expressions in workflow parameters, potentially achieving remote code execution in environments running vulnerable n8n versions.
Affected context
This vulnerability occurs in n8n instances where users can author or modify workflows that include dynamic expressions in node parameters.
The risk is present when:
- Expression evaluation is enabled and used to compute values at runtime
- Workflow designers can input free-form expressions without strong sandboxing
- The n8n server process runs with access to sensitive system resources or internal networks
It is particularly relevant in multi-user deployments or shared automation environments where not all users are fully trusted.
Exploit preconditions
- Attack surface: n8n's web interface and API for workflow creation and editing.
- Required access: Authenticated account with permission to create or modify workflows (or specific nodes/parameters that support expressions).
- Trigger point: Execution of a workflow containing malicious expressions in parameters, typically when the workflow is run manually, triggered by an event, or executed on a schedule.
- Why exploitation is possible: The expression evaluation engine insufficiently isolates or validates expression content, allowing it to resolve into constructs that are ultimately executed as system commands on the host instead of being treated purely as data.
Why this happens
The underlying issue stems from unsafe handling of user-controlled expressions within n8n's expression evaluation engine.
Instead of treating expressions as constrained, declarative templates, the engine permits constructs that can influence low-level command execution on the host system.
This aligns with CWE-94: Improper Control of Generation of Code ('Code Injection'), where attacker-controlled input is incorporated into an evaluation context that can generate or execute code.
In abstract terms, the system creates a bridge from "expression string" to "runtime code or OS command" without adequately constraining the allowed operations, leading to the possibility of arbitrary command execution when a workflow runs.
Potential impact
- Execution of arbitrary system commands on the host running n8n
- Access to environment variables, configuration secrets, and API keys reachable from the n8n process
- Unauthorized access to internal services or databases reachable from the n8n host
- Exfiltration or tampering of workflow data and connected system data
- Use of the n8n host as a pivot point for further lateral movement within the infrastructure
- Denial-of-service by consuming system resources or disrupting the n8n process
General mitigation guidance
Effective mitigation focuses on reducing the power of expression evaluation and narrowing trust boundaries around workflow authors:
- Treat all dynamic expressions as untrusted input and avoid feeding them directly into code or command execution paths.
- Introduce strict whitelisting in the expression language, exposing only safe, side-effect-free functions and removing any capability that can interact with the underlying operating system or unrestricted execution primitives.
- Enforce clear separation between data transformation logic and any functionality that runs system-level commands or scripts.
- Apply least-privilege to the n8n runtime: run the service under a dedicated low-privilege account, restrict file system and process-level capabilities, and isolate it using containers or sandboxes where feasible.
- Limit workflow creation and editing permissions to trusted users and apply role-based access controls that distinguish between read-only, execution-only, and authoring privileges.
- Regularly review workflows that use advanced expressions or powerful nodes, especially in shared or multi-tenant environments.
How teams detect issues like this
Detection approaches can combine configuration review, static analysis of workflow definitions, and runtime monitoring:
- Implement automated checks that scan stored workflow definitions for suspicious expression patterns, such as references to command execution helpers, shell-like constructs, or unusual use of advanced expression features.
- Use policy-based controls to flag or block workflows that include high-risk expressions or nodes, routing them for manual security review before activation.
- Enable logging of expression evaluation and workflow execution outcomes; monitor logs for anomalies such as unexpected command invocations, access to sensitive paths, or unusual failure patterns.
- During code review of the platform itself or custom extensions, look for any paths where expression outputs are passed to process-spawning APIs, dynamic evaluation constructs, or OS-level interfaces without strict mediation.
- Complement these measures with general runtime monitoring of the n8n host for unusual processes, network connections, or file-access patterns indicative of command injection abuse.

