Summary
A command injection vulnerability in n8n's community package installation feature allows authenticated administrators to execute arbitrary system commands on the n8n host.
Under specific configuration and usage conditions, crafted package inputs can be interpreted as shell commands, leading to high-impact compromise of the underlying server.
Affected context
This vulnerability affects n8n instances running versions 0.187.0 up to (but not including) 1.120.3 that enable and use the community package installation functionality.
It is relevant in deployments where:
- Administrative accounts are available (including shared or service accounts)
- Admins can supply or approve package names or installation parameters
- The n8n host has access to sensitive data, credentials, or internal services
The risk increases in environments where the n8n process runs with elevated OS privileges or is deployed on shared infrastructure.
Exploit preconditions
- Attack surface: n8n web interface or API that exposes community package installation to authenticated administrators.
- Required access: Valid n8n account with administrative permissions; the vulnerability is not directly exploitable by anonymous users.
- Trigger point: Initiating or approving installation of community packages with attacker-controlled input (e.g., package name or related parameters) that flows into shell command construction.
- Why exploitation is possible: User-supplied data is insufficiently validated and then interpolated into a command execution context, allowing shell metacharacters or command fragments to be interpreted by the underlying OS.
Why this happens
The core issue is improper handling of untrusted input in a command execution context, mapping to CWE-78: Improper Neutralization of Special Elements used in an OS Command.
The community package installation workflow appears to build or pass shell commands using values derived from administrator-controlled inputs without strict validation, sanitization, or use of parameterized execution APIs.
Additionally, the absence of robust input validation and normalization (CWE-20: Improper Input Validation) allows dangerous characters and sequences to reach the OS layer, enabling command injection rather than treating the input as inert data.
Potential impact
- Execution of arbitrary system commands under the n8n process user on the host machine
- Reading, modification, or deletion of workflow data and configuration files
- Extraction of credentials, API keys, and other secrets accessible to the n8n environment
- Lateral movement to other internal systems reachable from the n8n host
- Disruption of service availability, including denial of service or full takeover of the n8n instance
General mitigation guidance
Effective mitigation focuses on removing direct command construction with user-controlled data and tightening trust boundaries around administrative features:
- Replace shell-based execution with high-level, parameterized APIs (e.g., library calls or process execution functions that avoid invoking a shell).
- Apply strict allowlists for package identifiers and other installation parameters, ensuring they match well-defined formats and do not contain shell metacharacters.
- Normalize and validate all inputs associated with package installation before use; reject anything outside expected patterns instead of attempting to escape everything.
- Run the n8n service under a dedicated, least-privileged OS account with minimal filesystem and network access to limit blast radius if exploitation occurs.
- Restrict administrative access to trusted personnel and avoid sharing admin credentials or tokens across teams or automation tools.
- Where practical, separate n8n from highly sensitive infrastructure, using network segmentation and isolation to reduce the impact of a compromise.
How teams detect issues like this
Detection hinges on identifying risky command construction patterns in code and monitoring for anomalous behavior at runtime:
- Use static analysis or manual code review to locate any use of shell execution APIs (e.g., child process spawns, shell invocations) that concatenate or interpolate user- or admin-controlled strings.
- Check for insufficient input validation around parameters used in community package installation, such as unbounded strings or acceptance of special characters without justification.
- Implement logging for package installation actions, including which user initiated them and the associated parameters; monitor logs for unexpected or malformed values.
- Employ host-based intrusion detection or EDR solutions to flag unusual child processes spawned by the n8n service, especially those executing network tools, interpreters, or administrative utilities.
- Integrate secure coding checks and security-focused linters into CI pipelines to enforce policies that prohibit direct shell invocation with untrusted input.

