Summary
An authenticated code injection vulnerability in n8n allows a user who can create or modify workflows to achieve remote code execution on the n8n host.
By combining the Read/Write Files from Disk node with git operations, an attacker can write malicious configuration and trigger arbitrary shell commands during git execution.
Affected context
This vulnerability affects n8n instances where:
- Users are allowed to create or edit workflows, and
- The "Read/Write Files from Disk" node is enabled, and
- Workflows can trigger git-related operations that run on the n8n host.
In such deployments, workflows effectively gain indirect access to host-level configuration and command execution mechanisms, increasing the risk if users are not fully trusted.
Exploit preconditions
- Attack surface: Authenticated n8n web interface / API used to design and run workflows.
- Required access: Ability to create or modify workflows that include both file system access and git operation steps.
- Trigger point: Execution of a crafted workflow that writes controlled data into configuration files and then runs a git operation on the host.
- Why exploitation is possible: Workflow nodes expose file write capabilities and git commands without sufficient separation between user-controlled content and the execution context, enabling user input to influence commands or configuration interpreted by git.
Why this happens
The root cause is a code injection condition where user-controllable workflow steps can write to files that are later interpreted in an executable context by git.
This aligns with CWE-94: Improper Control of Generation of Code ('Code Injection'), as workflow authors can generate or modify configuration that ultimately leads to execution of attacker-influenced shell commands on the n8n host.
Conceptually, the platform grants workflows a level of file system and tooling control that is equivalent to scripting on the host, without adequate safeguards around where files may be written or how subsequent operations consume that data.
Potential impact
- Execution of arbitrary shell commands on the n8n host.
- Compromise of the n8n instance, including access to workflow definitions, credentials, and environment secrets.
- Lateral movement to other systems reachable from the compromised host.
- Data exfiltration or tampering within automated workflows.
- Use of the host as a pivot point for further attacks in the environment.
General mitigation guidance
Effective mitigation usually combines permission hardening with tighter control of powerful workflow nodes and host interactions:
- Restrict workflow creation and editing capabilities to highly trusted users and service accounts.
- Minimize or disable nodes that provide direct file system access or shell-adjacent behavior when not strictly required.
- Isolate automation infrastructure (like n8n) from sensitive hosts by using containers, sandboxes, or separate worker processes with reduced privileges.
- Apply least-privilege principles to the n8n runtime user, limiting file system paths and system tools it can affect.
- Introduce policy or governance over which nodes and integrations are allowed in production workflows, favoring higher-level, parameterized operations over raw command execution.
How teams detect issues like this
Organizations can look for this pattern both in configuration and in workflow content:
- Review workflows for combinations of nodes that provide file write capabilities and subsequent git or shell-like operations, especially those that touch configuration directories.
- Use static analysis or linting rules for workflow definitions to flag use of high-risk nodes (file system, git, command execution) in the same workflow or execution path.
- Implement code review practices for workflows, treating them as infrastructure-as-code artifacts subject to security review before deployment.
- Monitor host logs and application telemetry for unusual git operations or command patterns initiated by workflows.

