Summary
A command injection flaw in Coolify's deployment handling allows authenticated users with application write permissions to inject arbitrary shell commands via deployment-related fields.
When exploited during application deployment, this can lead to remote code execution on managed servers and exposure of sensitive environment variables through deployment logs.
Affected context
This vulnerability occurs in Coolify instances where application deployments are configured and triggered by users who hold write permissions on the affected application.
Risk is present when deployment parameters such as dockerfile_location and deployment command fields are passed to shell execution routines without robust sanitization, escaping, or contextual validation.
The issue is most relevant in environments where deployment pipelines run with access to sensitive environment variables, secrets, or privileged system resources.
Exploit preconditions
- Attack surface: Application deployment workflows within the Coolify web interface or its associated APIs.
- Required access: Authenticated access with application write permissions (ability to configure or modify deployment settings).
- Trigger point: Execution of a deployment that uses user-controlled fields such as
dockerfile_locationor custom deployment commands. - Why exploitation is possible: User-supplied deployment parameters are incorporated into shell commands or scripts without strict validation, escaping, or contextual separation, enabling shell metacharacters and arbitrary command sequences to be executed.
Why this happens
The underlying bug class aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
In abstract terms, the deployment logic treats user-controllable configuration fields as trusted command fragments and concatenates or interpolates them into shell invocations.
Without systematic neutralization of special characters or use of safer execution primitives that separate data from commands, attackers can craft input that alters the intended command structure and introduces arbitrary operations.
This insecure pattern often arises when deployment tooling favors flexibility and direct shell control over strict parameterization and context-aware validation.
Potential impact
- Remote code execution on the server or container running the deployment process.
- Exfiltration of sensitive environment variables and secrets via deployment logs or command output.
- Modification, deletion, or corruption of application data and configuration.
- Pivoting to other services or infrastructure components reachable from the compromised deployment environment.
- Installation of backdoors or persistent malicious tooling within managed servers or containers.
General mitigation guidance
Effective mitigation centers on reducing the trust placed in user-controlled deployment parameters and eliminating direct string-based command construction.
Recommended patterns include:
- Using parameterized process execution APIs (e.g., exec-like calls that pass arguments as arrays) instead of shell command concatenation.
- Strictly validating deployment-related inputs against whitelists, expected formats, and allowed paths, rejecting or normalizing anything outside defined bounds.
- Avoiding dynamic inclusion of arbitrary user-specified command fragments; instead, expose higher-level deployment actions that map to predefined, vetted operations.
- Minimizing privileges for deployment processes, including limiting access to sensitive environment variables and restricting filesystem and network capabilities.
- Designing deployment logging to avoid automatically echoing high-sensitivity values or raw command output where unnecessary.
How teams detect issues like this
Detection typically involves a combination of code-level and operational controls:
- Static analysis rules that flag string concatenation or interpolation into shell execution APIs when user-input or configuration fields are involved.
- Code review checklists that specifically examine deployment and orchestration logic for command construction, shell usage, and unvalidated parameters.
- Application security policies that constrain where and how shell commands may be invoked, enforcing use of safer process execution patterns.
- Runtime monitoring and logging to detect anomalous deployment commands, unexpected environment variable access, or unusual process behavior during deployments.
- Optional use of automated secure coding tools integrated into CI/CD to surface OS command injection patterns before they reach production.

