Summary
Coolify contained an OS command injection flaw where log drain secrets and environment values were interpolated directly into shell commands without proper encoding.
An authenticated user able to configure or control these values could inject additional commands, leading to arbitrary code execution on the host where Coolify runs.
Affected context
This vulnerability appears in Coolify deployments where:
- Log drains or similar features construct shell commands using user-controlled secrets or environment values
- Command strings are assembled through interpolation or concatenation without shell-safe encoding
- The resulting commands are executed on the underlying host or container shell
It becomes most relevant in environments where authenticated users can configure log drains, secrets, or environment variables that are later used in shell-based integrations.
Exploit preconditions
- Attack surface: Coolify management interface or API for configuring log drains and related environment values
- Required access: Authenticated access with permissions to define or modify log drain secrets or environment variables
- Trigger point: Execution of the log drain or any feature that invokes the constructed shell command
- Why exploitation is possible: User-supplied values are interpolated into shell commands without robust quoting, escaping, or use of non-shell execution primitives, allowing crafted input to break out of the intended command context
Why this happens
The core issue stems from constructing shell commands by interpolating user-controlled data and then executing them through a shell interpreter.
This maps directly to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where special shell metacharacters are not neutralized before being passed to the shell.
Conceptually, the pattern is:
- Take configuration values (secrets, environment variables) as trusted
- Embed them directly into a command string
- Execute that command via a shell, granting the attacker influence over the final command line
Because the shell treats certain characters as control operators, an attacker can append, chain, or replace commands beyond the intended operation.
Potential impact
- Authenticated users may execute arbitrary commands on the Coolify host
- Compromise of the Coolify instance, including its configuration and managed applications
- Access to sensitive data such as other users' configurations, secrets, and environment variables
- Lateral movement into other services or infrastructure reachable from the host
- Disruption of services through deletion, modification, or shutdown of managed resources
General mitigation guidance
Effective mitigation focuses on eliminating direct shell exposure and reducing trust in configuration inputs:
- Prefer API or library calls over shell commands for system interactions, avoiding
sh/bashaltogether where possible - When shell invocation is unavoidable, construct argument arrays and use exec-style APIs that bypass shell parsing
- Apply strict validation and allowlists for configuration fields that may influence commands, restricting them to expected formats
- Ensure secrets and environment values are never treated as free-form command fragments; apply conservative escaping and quoting when they must be passed to shell commands
- Run Coolify and related processes under least-privileged accounts to constrain damage if a command is injected
- Segregate management interfaces and limit which roles can configure log drains or other shell-influencing settings
How teams detect issues like this
Organizations can detect similar issues by:
- Using static analysis rules that flag string interpolation or concatenation passed into generic command execution functions (e.g., wrappers around
sh,bash, or platform-specific shells) - Reviewing code for patterns where secrets, environment variables, or configuration fields are embedded into command strings without central escaping utilities
- Enforcing coding guidelines that prohibit direct shell invocation in favor of safer abstractions and build-time checks to prevent violations
- Logging and monitoring command execution paths for anomalous or user-specific patterns that may indicate injection attempts
- Including targeted security tests that provide crafted configuration values to log drain and integration features to observe whether they alter command behavior

