Summary
Coolify versions up to and including v4.0.0-beta.434 contain a command injection vulnerability in the git source input fields used when configuring a resource.
A low-privileged member user can craft malicious git source values that are incorporated into system commands, resulting in arbitrary command execution as root on the Coolify instance under certain configurations.
Affected context
The vulnerability affects Coolify deployments where:
- Users with member-level access can create or modify resources that use git repositories as sources.
- Git source input fields are processed and passed to the underlying system as part of shell commands.
- The Coolify process or related worker components execute these commands with elevated privileges (commonly root).
The issue is most relevant in multi-user environments where members are granted access to configure or edit application sources through the Coolify UI or API.
Exploit preconditions
- Attack surface: Coolify web interface or API endpoints that accept git source input for resources.
- Required access: Authenticated, low-privileged user (member) capable of creating or modifying resources and setting git-related fields.
- Trigger point: Submission or update of a resource configuration that causes Coolify to execute git-related operations (e.g., clone, fetch, or update) using the provided input.
- Why exploitation is possible: User-controlled git source values are interpolated into shell commands or command-line arguments without sufficient sanitization or safe escaping, enabling injection of additional shell metacharacters or commands.
Why this happens
The root cause aligns with CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').
Application logic constructs system-level commands (likely involving git operations) by concatenating or interpolating untrusted input from git source configuration fields into command strings.
Because these inputs are not properly escaped, validated, or passed via parameterized execution APIs, the shell interprets special characters (such as separators, operators, or redirection symbols) as part of the command language.
This allows attackers to break out of the intended git command context and inject arbitrary system commands that the Coolify process executes with its own privileges, which may be root on the host.
Potential impact
- Execution of arbitrary system commands as root on the Coolify instance.
- Complete takeover of the underlying server (installation of backdoors, creation of privileged users, disabling of security controls).
- Unauthorized access to application secrets, environment variables, database credentials, and deployed application data.
- Modification, deletion, or exfiltration of hosted application and database data.
- Use of the compromised Coolify host as a pivot point for lateral movement within the infrastructure.
- Deployment pipeline and configuration tampering, potentially impacting all applications managed by Coolify.
General mitigation guidance
Mitigation focuses on eliminating direct command construction from untrusted input and enforcing strong input handling around git-related operations:
- Avoid building shell command strings directly from user inputs; instead, use parameterized process execution APIs that do not invoke a shell and treat arguments as data (for example, exec-style calls with argument arrays).
- Apply strict input validation and allowlisting on git source fields, restricting them to expected formats (e.g., well-formed repository URLs or specific protocols) and rejecting unexpected characters such as shell metacharacters and control operators.
- Normalize and canonicalize repository URLs before use, and consider mapping user-selectable sources to predefined, trusted configurations rather than free-form input whenever possible.
- Run the Coolify service and any worker processes handling git operations with the least privileges necessary, avoiding root execution where feasible and isolating them in containers or restricted OS-level sandboxes.
- Separate configuration responsibilities so that only trusted administrators can define or approve git source values used in production resources, reducing the attack surface from low-privileged users.
- Introduce defense-in-depth controls such as mandatory logging and monitoring of command execution paths to quickly identify unexpected behavior in deployment workflows.
How teams detect issues like this
Detection strategies typically involve both code-centric and operational approaches:
- Static analysis and code scanning:
- Search for usage of shell-invoking APIs (e.g., system(), popen(), exec with shell=true, or equivalent) that concatenate or interpolate user-input strings related to git operations.
- Flag patterns where git repository URLs, branches, or custom arguments are passed unsafely into command strings without escaping or validation.
- Code review practices:
- During review, pay explicit attention to any functionality that invokes git or other CLI tools based on web or API inputs.
- Require reviewers to confirm that all external command invocations use argument arrays or proper escaping and do not rely on free-form shell evaluation.
- Runtime monitoring and logging:
- Enable detailed logging for command execution paths used by Coolify to fetch or deploy code, capturing both the command-line arguments and the initiating user context.
- Monitor for suspicious patterns such as unusual shell operators, redirections, or unexpected binaries invoked during git-related operations.
- Security policy enforcement:
- Integrate automated security checks into CI/CD pipelines to detect known unsafe command execution patterns.
- Use application security testing (SAST/DAST) tools that understand command injection signatures and flag risky parameters and endpoints.

