/

CVE-2026-42153

Severity:

HIGH RISK

(8.8)

OS Command Injection (CWE-78) in Coolify PostgreSQL Checks

CVE-2026-42153

Deferred

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Arbitrary Command Execution in Container

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A command injection vulnerability in Coolify's PostgreSQL healthcheck logic allows attacker-controlled database settings to be embedded directly into shell-form commands.

An authenticated user who can configure PostgreSQL connection parameters may inject arbitrary commands that execute inside the database container.

Affected context

The vulnerability appears in environments running Coolify versions prior to 4.0.0-beta.474 where PostgreSQL healthchecks are implemented as shell-form commands.

In these setups, user-configurable fields such as postgres_user and postgres_db are interpolated directly into command strings that run inside the PostgreSQL container.

The issue becomes relevant when users have permissions to create or edit database configurations and when these configurations are used to drive healthcheck or management commands.

Exploit preconditions

  • Attack surface: Coolify PostgreSQL integration and healthcheck mechanism
  • Required access: Authenticated access with the ability to define or modify PostgreSQL connection settings (e.g., postgres_user, postgres_db)
  • Trigger point: Execution of the generated PostgreSQL healthcheck command within the database container
  • Why exploitation is possible: Unvalidated and unsanitized user-controlled values are embedded into shell-form commands, allowing shell metacharacters and additional commands to be interpreted by the shell.

Why this happens

The core problem stems from constructing shell commands by concatenating or interpolating user-supplied values without robust validation or escaping.

This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, where attacker-controlled input is passed to a shell interpreter and treated as part of the command line.

Instead of treating PostgreSQL connection parameters as data passed to a safe API, the implementation relies on shell parsing, allowing crafted input to break out of the intended command and inject additional operations.

Potential impact

  • An authenticated attacker may execute arbitrary shell commands within the PostgreSQL container.
  • Attackers could read or modify data accessible from the compromised container.
  • The attacker can establish persistence or deploy additional tooling inside the container.
  • Depending on container privileges and network topology, the attacker could pivot to other services or hosts reachable from the database container.
  • Application availability could be disrupted by stopping services, corrupting data, or exhausting resources.

General mitigation guidance

Effective mitigation focuses on eliminating the dependency on shell parsing for operational commands and strictly separating code from data.

Recommended defensive patterns include:

  • Avoid constructing shell-form command strings with user-supplied values; instead use parameterized APIs (e.g., direct database drivers) or exec-form process invocation where arguments are passed as an array.
  • Treat all configuration values, such as usernames and database names, as untrusted data and apply strict allowlists for expected formats (e.g., alphanumeric plus a small set of safe characters).
  • Centralize command creation logic with a small, well-reviewed abstraction that handles quoting or, preferably, does not use a shell at all.
  • Run containers with least privilege, minimizing filesystem, network, and OS capabilities to reduce blast radius if command execution occurs.
  • Limit which roles or tenants are permitted to create or change sensitive connectivity parameters used by automated healthchecks or maintenance jobs.

How teams detect issues like this

Detection typically involves both code-centric and runtime approaches:

  • Static analysis: Search for shell execution APIs (e.g., sh, bash, exec, child_process, or similar) where arguments are built from configuration fields like postgres_user and postgres_db. Flag any concatenation or interpolation into a single string.
  • Code review: Pay attention to healthcheck, monitoring, and automation code that often escapes direct security review; verify that configuration values are passed as data, not as part of shell command strings.
  • Security policy enforcement: Introduce linters or CI policies that disallow shell-form command construction with untrusted input or require explicit justification and review for such patterns.
  • Runtime monitoring: Observe container logs and command execution traces for unusual arguments or unexpected processes spawned by healthcheck routines, which may indicate attempted command injection.

Sources

SourceLink
github.comgithub.com/coollabsio/coolify/commit/b74f54302b1a857c22c55fe1210d700859b0b3df
github.comgithub.com/coollabsio/coolify/pull/9674
github.comgithub.com/coollabsio/coolify/releases/tag/v4.0.0-beta.474
github.comgithub.com/coollabsio/coolify/security/advisories/GHSA-gvc4-f276-r88p

Frequently asked

questions

It depends on how Coolify is exposed. Exploitation requires authenticated access to the Coolify interface or API with the ability to manipulate PostgreSQL configuration fields. If that access is available remotely, the vulnerability can be exploited remotely.

The attacker needs valid credentials and permissions within Coolify to create or modify PostgreSQL settings that feed into the healthcheck command, such as postgres_user and postgres_db. No direct shell access to the container is required.

The most robust fix is to stop using shell-form commands built from user-controlled strings and instead invoke healthcheck logic through safe, parameterized APIs or exec-form calls that pass arguments as data rather than through a shell. Additionally, enforce strict validation on all configuration fields used in operational commands.

Adopt a development guideline that prohibits interpolating untrusted input into shell commands, enforce this policy with automated checks in CI, and prefer libraries or frameworks that handle command execution without relying on a shell. Regular security-focused code reviews for healthchecks, automation scripts, and configuration-driven logic can help catch injection risks early.

Find out what's already
exploitable in your codebase.