Summary
Coolify contains an OS command injection vulnerability in Docker commands executed over SSH when environment variable key names are not properly escaped. An authenticated attacker who can control affected environment variable keys may execute arbitrary commands on a managed server host outside its containers.
Affected context
The vulnerability occurs in Coolify deployments that use managed servers and execute Docker-related commands over SSH. It becomes risky when an authenticated user can influence environment variable key names that are incorporated into shell commands without complete escaping or safe argument handling.
Exploit preconditions
- Attack surface: SSH-based command execution on a Coolify-managed server
- Required access: Authenticated access sufficient to create or modify deployment environment variables
- Trigger point: Construction and execution of a Docker command containing an attacker-controlled environment variable key
- Why exploitation is possible: Shell metacharacters in the key name may be interpreted as command syntax rather than treated as data
Why this happens
The underlying bug is failure to treat environment variable key names as untrusted data when constructing shell commands. If user-controlled values are concatenated into a command without robust argument handling or context-aware escaping, shell metacharacters can alter command interpretation. This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, commonly known as OS command injection.
Potential impact
- An attacker may execute arbitrary commands on the managed server host
- The attacker could access host files, credentials, or deployment data permitted to the command context
- Running services and deployment workloads may be modified or disrupted
- The server could be used for lateral movement or further compromise
- Container isolation may be bypassed where host-level command execution is available
General mitigation guidance
Mitigation generally focuses on preventing user-controlled strings from becoming shell syntax.
Common defensive patterns include:
- Passing command arguments through structured process-execution APIs instead of shell-evaluated strings
- Applying strict allowlists for environment variable key names and rejecting invalid characters
- Separating command construction from data serialization and using safe argument encoding
- Reducing the privileges of the SSH account and deployment automation
- Limiting access to managed-server configuration and deployment controls
- Avoiding unnecessary host-level capabilities and isolating deployment workers where practical
How teams detect issues like this
Detection approaches may include:
- Static analysis searches for shell command construction involving environment variable names or other user-controlled fields
- Code review checks for string concatenation, interpolation, or shell wrappers around Docker and SSH commands
- Runtime monitoring for unexpected child processes, shell metacharacters, or commands launched by deployment identities
- Policy enforcement requiring structured process APIs, input allowlists, and least-privilege service accounts
- Automated security review tools that flag command execution paths receiving externally controlled input

