Summary
A command injection flaw in the n8n Git node allows authenticated users who can create or modify workflows to execute arbitrary system commands or read arbitrary files on the n8n host.
The vulnerability is triggered when attacker-controlled input is passed into Git-related operations without proper sanitization, making any n8n instance with untrusted workflow authors at risk.
Affected context
This issue affects n8n deployments that expose the Git node to users who can design or edit workflows.
The vulnerable behavior appears when user-supplied values in workflow configuration (e.g., repository paths, options, or command parameters) are concatenated or interpolated into Git-related shell commands without adequate validation or escaping.
Any environment where workflow authors are not fully trusted, or where a compromised account can modify workflows, is particularly exposed.
Exploit preconditions
- Attack surface: n8n Git node used within workflows on the n8n instance.
- Required access: Authenticated account with permission to create or modify workflows that leverage the Git node.
- Trigger point: Execution of a workflow containing a maliciously configured Git node, either manually triggered, scheduled, or invoked via webhooks or integrations.
- Why exploitation is possible: User-controlled workflow fields are incorporated into underlying system commands without strict validation, escaping, or use of a safe API, enabling injection of additional commands or redirection to sensitive files.
Why this happens
The underlying bug aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command (OS command injection).
The Git node appears to construct or invoke operating system commands using parameters that can be influenced by workflow authors.
When application code directly interpolates user-supplied values into command strings or passes them to shells without rigorous sanitization and context-aware escaping, the shell interprets special metacharacters (such as separators, redirections, or subshell operators) as additional commands.
This pattern turns otherwise benign workflow configuration parameters into a vehicle for executing arbitrary commands or reading arbitrary files on the host system.
Potential impact
- Execution of arbitrary system commands with the privileges of the n8n process.
- Unauthorized reading of arbitrary files on the n8n host, including configuration files and potentially secrets.
- Lateral movement within the hosting environment, depending on network connectivity and service trust relationships.
- Data exfiltration from local storage or connected services reachable from the n8n instance.
- Service disruption via destructive commands (e.g., deleting files, exhausting resources).
- Escalation of impact if the n8n process runs with elevated or overly broad privileges.
General mitigation guidance
Mitigation centers on removing direct command construction paths and reducing trust in workflow-supplied parameters:
- Use high-level, parameterized APIs or libraries for Git operations instead of shelling out to system commands whenever possible.
- If OS commands are unavoidable, pass parameters as discrete, non-shell-escaped arguments (e.g., using exec functions that bypass the shell) and apply strict allowlists for expected values.
- Enforce strong validation on Git node inputs: constrain acceptable formats, disallow metacharacters, and reject unexpected options or paths.
- Treat workflow authors as potentially untrusted in multi-tenant or shared deployments; segment tenants and restrict high-risk nodes to trusted users only.
- Run the n8n process under a dedicated, minimally privileged account with restricted filesystem and network access to limit damage if injection occurs.
- Isolate the n8n runtime using containers, sandboxes, or separate hosts, particularly when enabling nodes that interact with the underlying system.
How teams detect issues like this
Possible detection strategies include:
- Static analysis and code scanning:
- Flag code patterns where user-controlled data flows into command construction, especially around the Git node implementation.
- Detect usage of shell-invoking APIs (e.g., generic exec with string commands) paired with workflow configuration inputs.
- Code review practices:
- Require security-focused review for any feature that spawns OS processes or interacts with the host filesystem.
- Look for absence of strict validation, allowlists, or argument-based APIs in Git-related code paths.
- Runtime monitoring and logging:
- Log command invocations from the n8n service, including arguments; alert on suspicious patterns (e.g., use of shell metacharacters, redirection, or unexpected binaries).
- Monitor filesystem access from the n8n process for anomalous reads of sensitive files.
- Policy and CI enforcement:
- Integrate security linters and SAST tools into CI pipelines to detect command injection patterns before deployment.
- Enforce development policies that prohibit direct shelling out from nodes when safer library APIs are available.

