/

CVE-2026-42200

Severity:

HIGH RISK

(8.8)

Path Traversal (CWE-22) in Coolify PostgreSQL Setup

CVE-2026-42200

Deferred

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Authenticated Remote Code Execution via Filesystem Write

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

Coolify's PostgreSQL initialization flow insufficiently restricted script file paths, allowing authenticated users to write initialization files outside the intended directory.

In environments where database init scripts are executed automatically, a malicious user could leverage this path traversal to run arbitrary commands on the underlying server.

Affected context

The vulnerability appears in Coolify deployments that rely on its built-in PostgreSQL management and initialization scripting.

It is relevant when authenticated users can supply or influence initialization script names or locations, and when those scripts are later executed by the database startup process without additional validation.

The issue manifests at the boundary where application-level file creation meets underlying OS paths, especially in multi-tenant or shared Coolify instances.

Exploit preconditions

  • Attack surface: Coolify's PostgreSQL management and initialization features exposed through the authenticated application interface.
  • Required access: Valid authenticated access to a Coolify instance with permissions to configure or start PostgreSQL databases.
  • Trigger point: Creation or regeneration of PostgreSQL initialization scripts via the generate_init_scripts() routine, which writes files based on user-influenced filenames.
  • Why exploitation is possible: The filename handling lacks robust path normalization and restriction to a dedicated directory, enabling directory traversal sequences to escape the intended folder and deposit executable initialization content elsewhere that the startup process will run.

Why this happens

This issue stems from improper validation and normalization of file paths before writing initialization scripts.

User-controlled or user-influenced input is incorporated into filesystem paths without rejecting directory traversal patterns, symbolic link abuse, or other mechanisms that break confinement to a designated directory.

Conceptually, this maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where code assumes that a target directory boundary is enforced but fails to sanitize or canonicalize the path, allowing attackers to escape the intended location and place files in more sensitive locations.

Potential impact

  • Authenticated users could write arbitrary files outside the intended PostgreSQL init directory.
  • Attackers may place malicious shell or SQL scripts that are executed during database initialization.
  • Arbitrary command execution on the database host under the privileges of the database or application service account.
  • Escalation of access within the managed server, including tampering with application data or configuration.
  • Establishment of persistence mechanisms by placing backdoored scripts or configuration files.

General mitigation guidance

Mitigation focuses on strict confinement of file operations and reduction of trust in user-supplied paths.

Defensive patterns include:

  • Enforcing canonical path resolution and verifying that resulting paths reside strictly under a pre-defined, whitelisted directory.
  • Rejecting any input that contains directory traversal sequences, absolute paths, or null bytes, and only allowing a constrained, validated filename set.
  • Separating user-controlled names from actual filesystem paths by mapping logical identifiers to server-generated filenames.
  • Ensuring that any automatically executed initialization scripts are sourced only from directories that the application fully controls and that are not writable by untrusted users.
  • Running database initialization and management routines under least-privilege accounts with limited filesystem access to reduce the blast radius of misdirected writes.

How teams detect issues like this

Detection commonly involves both code-centric and operational approaches:

  • Static analysis: Rules that flag direct concatenation of user input into filesystem paths, especially for initialization scripts or configuration files, without normalization and directory checks.
  • Code review: Looking for file creation or write operations in database management components, ensuring they use hardened helper functions to validate paths and enforce directory boundaries.
  • Configuration review: Verifying that init script directories are not world-writable and that only trusted components can modify startup scripts.
  • Operational monitoring: Logging and alerting on unusual file creations near database binaries or configuration directories, and tracking unexpected changes to init scripts.

Automated secure coding tools and CI checks can be configured to detect directory traversal patterns and unsafe file path handling before deployment.

Sources

SourceLink
github.comgithub.com/coollabsio/coolify/commit/1cf6c7d0aef8e0edb800ae43f44ded102397cb13
github.comgithub.com/coollabsio/coolify/pull/9681
github.comgithub.com/coollabsio/coolify/releases/tag/v4.0.0-beta.474
github.comgithub.com/coollabsio/coolify/security/advisories/GHSA-mv4c-9x67-rrmv

Frequently asked

questions

It depends on how the Coolify instance is exposed. The issue requires authenticated access, so an attacker must first reach the Coolify interface and obtain valid credentials or compromise an existing account to exploit it.

An attacker needs authenticated access with the ability to manage or initialize PostgreSQL databases through Coolify. Anonymous or unauthenticated users cannot directly exploit this flaw.

The robust fix pattern is to normalize and validate all filesystem paths derived from user input and enforce that they remain inside a designated base directory, rejecting any path that attempts traversal or uses absolute references. Additionally, map user-visible identifiers to internally generated filenames rather than trusting raw user-supplied paths.

Adopt a consistent path-handling abstraction that centralizes directory enforcement, apply strict input validation on filenames, and integrate static analysis rules targeting directory traversal. Combine this with least-privilege filesystem permissions and regular security reviews of components that write configuration or initialization files.

Find out what's already
exploitable in your codebase.