Summary
A code injection vulnerability in n8n allows authenticated users to execute malicious code through the n8n service under certain workflow configurations.
When untrusted or semi-trusted users can create or modify workflows and leverage powerful nodes (such as Git or script-like nodes), this flaw can lead to full compromise of self-hosted or cloud-hosted n8n instances.
Affected context
The vulnerability affects n8n workflow automation deployments where authenticated users are allowed to define or modify workflows that can fetch, load, or execute external or user-controlled content.
It is most relevant in multi-user or shared environments, especially where:
- The Git node or similar nodes capable of fetching and executing external resources are enabled
- Users have permission to design or edit workflows without strict review
- The n8n instance is connected to sensitive infrastructure or data sources
Both self-hosted and n8n Cloud instances can be impacted when powerful workflow capabilities are exposed to untrusted or partially trusted users.
Exploit preconditions
- Attack surface: The n8n web interface and workflow execution engine, reachable by authenticated users with workflow editing or creation rights.
- Required access: An attacker must have a valid n8n account or access token with sufficient permissions to configure or modify workflows and use high-privilege nodes (e.g., Git node or script-capable nodes).
- Trigger point: The malicious code is executed when the crafted workflow runs, either manually, via a schedule, or through an external trigger (webhook, event, etc.).
- Why exploitation is possible: Workflow components implicitly trust content that they fetch, import, or assemble, and the platform executes this content with server-side privileges without enforcing adequate separation between untrusted workflow data and executable logic.
Why this happens
The underlying issue falls under CWE-94: Improper Control of Generation of Code, with an adjacent risk of CWE-434: Unrestricted Upload of File with Dangerous Type where workflows can effectively introduce and execute untrusted artifacts.
In abstract terms, an execution engine (n8n) allows users to design workflows that can:
- Pull arbitrary external content (e.g., from Git or other remote sources)
- Treat that content as executable logic or configuration without sufficiently constraining what can be executed
Because the system merges untrusted workflow-defined inputs with powerful execution primitives, attackers who control workflow configuration can cause the platform to generate or run malicious code within the n8n service context.
Potential impact
- Remote code execution on the n8n server or worker environment
- Full compromise of the n8n instance, including access to stored credentials, API keys, and integrations
- Lateral movement to connected systems through configured integrations (databases, cloud services, SaaS APIs)
- Exfiltration or tampering of workflow data processed by n8n
- Use of the n8n infrastructure as a pivot point for further attacks inside the hosting environment
General mitigation guidance
Mitigation strategies should aim to limit where and how untrusted content can influence executable logic, and to constrain user capabilities in multi-tenant or shared setups.
Conceptual mitigation patterns include:
- Restrict powerful nodes: Disable or tightly control nodes that can fetch external content or evaluate dynamic code (e.g., Git or script-like nodes) when they are not strictly necessary.
- Principle of least privilege for users: Segment users by trust level and assign minimal permissions needed for their workflows, avoiding granting unreviewed users the ability to design or alter high-impact workflows.
- Execution sandboxing: Run workflow execution components with reduced OS-level privileges, and isolate them from critical infrastructure using containerization, network policies, and minimal filesystem access.
- Configuration hardening: Treat workflow definitions as potentially untrusted input; use policies that restrict which nodes and operations can be used in certain projects, tenants, or environments.
- Separation of duties: Require review or approval for workflows that use nodes capable of executing code, interacting with secrets, or modifying critical systems.
How teams detect issues like this
Detection efforts should focus on identifying risky workflow patterns and monitoring for abnormal execution behavior.
Common approaches include:
- Static analysis of workflow definitions: Scan stored workflows for the use of high-risk nodes (e.g., Git, code-execution, or file-handling nodes), remote content sources, and patterns indicating dynamic evaluation of user-controlled data.
- Policy-based controls: Enforce rules that block workflows using certain node combinations or external sources unless they are explicitly approved or belong to trusted projects.
- Audit logging and review: Enable and regularly review logs of workflow changes, node usage, and execution results to spot suspicious modifications or sequences that deviate from normal operations.
- Runtime monitoring: Monitor host and container behavior for unusual processes, outbound connections, or file operations initiated from the n8n execution environment, and alert on anomalies.
- Automated review tooling: Integrate security checks into CI/CD or configuration pipelines that handle n8n workflow definitions, flagging dangerous patterns before they reach production.

