Summary
Coolify versions prior to 4.0.0-beta.445 contain a command injection flaw where parameters from docker-compose.yaml are passed unsanitized into shell commands.
If a user creates an application from a malicious repository using the "docker compose" build pack, an attacker can execute arbitrary commands on the Coolify instance with root privileges.
Affected context
This vulnerability manifests in Coolify deployments that:
- Allow users to create applications using the "docker compose" build pack
- Consume docker-compose.yaml content from external repositories (e.g., Git)
- Construct shell or CLI commands directly from values in docker-compose.yaml without robust sanitization or escaping
The risk is most pronounced when users connect repositories they do not fully control or trust, since repository owners can influence docker-compose parameters that Coolify uses in commands.
Exploit preconditions
- Attack surface: Coolify's application creation and deployment workflow using the "docker compose" build pack.
- Required access: Ability to control or influence the repository from which a victim user creates an application (e.g., owning the repo, or convincing the victim to use an attacker-controlled repo).
- Trigger point: The moment Coolify parses docker-compose.yaml and constructs shell commands that include unsanitized parameters.
- Why exploitation is possible: User-controlled values from docker-compose.yaml are interpolated into shell commands without proper validation, escaping, or use of safer, argument-based process execution APIs, enabling attackers to inject additional shell syntax.
Why this happens
The underlying issue aligns with CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').
Coolify's code path for handling docker-compose-based applications takes parameters from docker-compose.yaml and embeds them directly into shell commands.
Because these values are treated as part of a command string instead of distinct arguments, shell metacharacters (such as separators, redirection, or subcommands) can alter the intended command structure.
This pattern converts configuration data into executable shell logic without neutralizing special characters, allowing attacker-controlled configuration to break out of its expected role and execute arbitrary commands.
Potential impact
- Execution of arbitrary commands on the Coolify host as root.
- Complete compromise of the Coolify instance, including stored credentials and configuration.
- Lateral movement to other services, containers, or networks managed by the affected server.
- Modification or destruction of hosted applications and databases.
- Installation of persistent backdoors, cryptominers, or additional malware.
General mitigation guidance
Effective mitigation centers on treating all configuration-sourced values as untrusted and strictly separating data from commands:
- Use APIs that pass arguments as arrays (e.g., exec with argument vectors) instead of building shell command strings from concatenated text.
- Apply rigorous validation to docker-compose parameters, enforcing strict allowlists for expected values, formats, and character sets.
- Neutralize or reject values containing shell metacharacters or other control characters that are not necessary for legitimate operation.
- Encapsulate command execution within restricted contexts (e.g., non-root users, constrained containers, or sandboxes) to limit impact if a flaw occurs.
- Minimize the privileges of the Coolify process and associated service accounts, following least-privilege principles.
These patterns reduce the risk that future changes to docker-compose handling reintroduce command injection vectors.
How teams detect issues like this
Organizations can detect and monitor for similar issues and potential exploitation using a combination of code-level and operational approaches:
- Static analysis: Configure SAST tools or custom rules to flag string-based command construction, especially where user-controlled or configuration-derived values are concatenated into shell commands.
- Code review patterns: During review, treat any use of shell execution APIs as high-risk; look specifically for direct inclusion of values from docker-compose.yaml or other external configuration files.
- Security policies: Establish guidelines that prohibit shell command construction from untrusted input and encourage the use of parameterized process execution.
- Runtime monitoring: Use host and container monitoring to detect unusual command patterns, unexpected child processes spawned by Coolify, or commands executing from deployment workflows.
- CI/CD checks: Integrate automated code scanning and policy enforcement into the development pipeline to catch new command injection patterns before deployment.

