Summary
A regression in Coolify's shell command filtering for custom Docker Compose actions allows ampersands in build and deployment-related command fields, enabling command chaining.
An authenticated team member who can configure these commands may inject arbitrary shell instructions that execute on the underlying host whenever the affected actions run.
Affected context
This vulnerability occurs in Coolify deployments that use custom Docker Compose commands for build, start, or pre/post-deployment hooks.
It is relevant when team members are allowed to define or modify these commands through the Coolify UI and the platform relies on a shell-safe pattern to sanitize or constrain what can be executed.
The regression in SHELL_SAFE_COMMAND_PATTERN reintroduced support for ampersands, which can be used to chain multiple shell commands, increasing the attack surface on the host running Coolify and Docker.
Exploit preconditions
- Attack surface: Coolify web interface fields for custom Docker Compose build, start, and deployment hook commands.
- Required access: Authenticated access as a team member with permission to configure project or deployment commands.
- Trigger point: Execution of the configured Docker Compose command or deployment hook by Coolify during normal operational workflows.
- Why exploitation is possible: The regression in SHELL_SAFE_COMMAND_PATTERN fails to properly restrict shell metacharacters such as ampersands, allowing crafted input that the shell interprets as multiple commands, enabling arbitrary command execution on the host.
Why this happens
The underlying bug class is command injection, mapped to CWE-78: Improper Neutralization of Special Elements used in an OS Command.
Coolify relies on a pattern-based filter (SHELL_SAFE_COMMAND_PATTERN) to limit what users can pass into shell-executed commands for Docker Compose operations.
The regression expanded allowable characters to include ampersands, a shell metacharacter used for command chaining and background execution, effectively breaking the trust boundary between user-supplied configuration and host-level shell execution.
Because the application constructs or forwards these strings directly to a shell without rigorous escaping or use of safer invocation mechanisms, user-controlled content can influence the structure of the executed command line rather than being treated as inert data.
Potential impact
- Authenticated users may execute arbitrary commands on the host running Coolify.
- Attackers could access or modify application, database, or system files on the host.
- Host-level compromise could allow installation of additional tooling or backdoors.
- Deployment pipelines and running containers can be tampered with or disrupted.
- Lateral movement to other services reachable from the compromised host may occur.
General mitigation guidance
Mitigation strategies focus on removing direct shell interpretation of user-controlled command strings and tightening the configuration trust model.
Secure patterns include:
- Avoiding construction of shell command lines from raw user input; prefer structured invocation APIs (e.g., parameterized process execution) that treat user values as arguments, not command fragments.
- Applying strict allowlists for permissible commands and arguments in deployment hooks, limiting users to predefined operations rather than arbitrary shell syntax.
- Enforcing robust validation that rejects shell metacharacters and control operators, rather than relying solely on regex filters that can regress.
- Running Coolify and its Docker engine with least privilege, isolating deployment processes from sensitive host resources where practical.
- Separating configuration roles so that only highly trusted administrators can define commands that run on the host, and using review/approval workflows for changes.
How teams detect issues like this
Effective detection involves both code-focused and configuration-focused approaches:
- Static analysis rules or manual code review to identify locations where user-supplied strings are passed into shell execution APIs without strict argument separation or escaping.
- Security review of command pattern filters (such as SHELL_SAFE_COMMAND_PATTERN) to ensure they implement conservative allowlists rather than permissive blocklists and to catch regressions when patterns change.
- Logging and monitoring of deployment and build commands executed by Coolify, including recording the full command line for anomaly detection and forensic analysis.
- Policy enforcement in CI/CD and configuration management pipelines that flags or requires approval for custom commands containing shell metacharacters or unexpected operations.
- Optional use of automated configuration scanning tools that look for high-risk command patterns in deployment orchestrators and platform settings.

