Summary
A command injection vulnerability in the n8n Git node allows Git configuration values from a repository to cause command execution during routine repository operations. An attacker who can provide or influence a repository with crafted local configuration may execute commands as the n8n process user.
Affected context
The vulnerability occurs in n8n versions that use the Git node to perform repository operations such as Add, Commit, Checkout, or Pull. It becomes risky when a repository's local Git configuration can reach the Git process and contains command-bearing content-filter or merge-driver settings with matching attribute patterns, while the node's configuration sanitization does not remove those key families.
Exploit preconditions
- Attack surface: The n8n Git node and its repository operation workflow
- Required access: Ability to cause n8n to process or operate on a repository containing attacker-controlled local Git configuration
- Trigger point: An ordinary Add, Commit, Checkout, or Pull operation performed by the Git node
- Why exploitation is possible: The node resets a fixed set of command-bearing configuration keys but does not cover content-filter and merge-driver key families, allowing Git to invoke configured commands when matching attributes are processed
Why this happens
The underlying bug is incomplete sanitization of command-capable Git configuration. The Git node attempted to clear a known list of dangerous configuration keys, but the allowlist or denylist did not cover all configuration families that can invoke external commands through Git attributes.
This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command or Argument, because attacker-influenced repository metadata can cause a trusted process to execute operating-system commands without sufficiently restricting the command-bearing behavior.
Potential impact
- Arbitrary commands may execute with the privileges of the n8n process
- The n8n runtime could be compromised
- Credentials, workflow data, or environment variables could be exposed
- An attacker could modify repositories, workflows, or generated artifacts
- The host or surrounding services could be affected, depending on process privileges and network access
General mitigation guidance
Mitigation generally focuses on treating repositories and Git metadata as untrusted input and preventing Git from invoking external commands during automated operations.
Common defensive patterns include:
- Using a strict allowlist of supported Git configuration and attribute behavior rather than clearing only known keys
- Disabling or isolating Git features that invoke external filters, merge drivers, hooks, or helpers when they are not required
- Processing repositories in disposable, sandboxed workers with minimal filesystem, network, and credential access
- Separating repository-processing identities from administrative n8n services
- Avoiding inherited credentials and reducing the runtime user's operating-system privileges
- Validating repository provenance and content before automated Git operations
- Applying secure-by-default Git configuration at the process and execution-environment boundaries
How teams detect issues like this
Detection approaches can include:
- Static analysis for incomplete sanitization of command-bearing Git configuration families
- Code review checks for repository operations performed on untrusted or user-supplied content
- Tests using repositories with unusual attributes, filters, merge drivers, hooks, and helper settings to verify that external execution is blocked
- Runtime monitoring for unexpected child processes spawned by the n8n process during Git activity
- Policy enforcement that restricts repository sources, disables unnecessary Git extensions, and alerts on execution from workspace-controlled paths
- Automated security review tools that identify command execution paths and insufficient input-trust boundaries

