Miggo Logo

CVE-2025-62725: Docker Compose Vulnerable to Path Traversal via OCI Artifact Layer Annotations

N/A

CVSS Score

Basic Information

EPSS Score
-
Published
10/27/2025
Updated
10/27/2025
KEV Status
No
Technology
TechnologyGo

Technical Details

CVSS Vector
-
Package NameEcosystemVulnerable VersionsFirst Patched Version
github.com/docker/compose/v2go< 2.40.22.40.2

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability lies in Docker Compose's handling of file paths from OCI artifact annotations, leading to a path traversal vulnerability. The analysis of the provided patch 69bcb962bfb2ea53b41aa925333d356b577d6176 pinpoints two primary vulnerable functions in pkg/remote/oci.go.

First, remote.ociRemoteLoader.pullComposeFiles was identified as vulnerable. This function, when processing a layer with a com.docker.compose.extends annotation, would unsafely use the value from the com.docker.compose.file annotation to construct a file path. This lack of sanitization created a path traversal flaw. The patch mitigates this by removing the vulnerable file creation logic.

Second, the remote.writeEnvFile function was also found to be vulnerable. It directly used the file path from the com.docker.compose.envfile annotation to create a file, without any validation. This allowed for a similar path traversal attack. The fix involves adding a call to a new validatePathInBase function, which ensures the path from the annotation is safe before any file operations are performed.

The core of the vulnerability is the failure to validate user-controllable input (the file paths in the annotations). An attacker could exploit this by creating a malicious OCI artifact with path traversal sequences (../) in the annotations. This would cause Docker Compose to write files outside of the intended cache directory, which could be leveraged for arbitrary code execution or other forms of system compromise. The functions remote.ociRemoteLoader.pullComposeFiles and remote.writeEnvFile are the precise locations where this insecure processing of malicious input occurred.

Vulnerable functions

remote.ociRemoteLoader.pullComposeFiles
pkg/remote/oci.go
The function `pullComposeFiles` was vulnerable to path traversal. When processing an OCI artifact layer with the `com.docker.compose.extends` annotation, it would use the value of the `com.docker.compose.file` annotation to construct a file path. This path was not validated, allowing an attacker to write a file outside of the intended cache directory by crafting a malicious path in the `com.docker.compose.file` annotation (e.g., `../../../../tmp/pwned`).
remote.writeEnvFile
pkg/remote/oci.go
The function `writeEnvFile` was vulnerable to path traversal. It retrieves a file path from the `com.docker.compose.envfile` annotation of an OCI artifact layer and uses it to create a file. The path was not validated, allowing an attacker to write an environment file to an arbitrary location on the filesystem by providing a malicious path like `../../../../etc/profile.d/attack.sh`.

WAF Protection Rules

WAF Rule

*o*k*r *ompos* trusts t** p*t* in*orm*tion *m****** in r*mot* O*I *ompos* *rti***ts. W**n * l*y*r in*lu**s t** *nnot*tions *om.*o*k*r.*ompos*.*xt*n*s or *om.*o*k*r.*ompos*.*nv*il*, *ompos* joins t** *tt**k*r‑suppli** v*lu* *rom *om.*o*k*r.*ompos*.*il

Reasoning

T** vuln*r**ility li*s in *o*k*r *ompos*'s **n*lin* o* *il* p*t*s *rom O*I *rti***t *nnot*tions, l***in* to * p*t* tr*v*rs*l vuln*r**ility. T** *n*lysis o* t** provi*** p*t** `****************************************` pinpoints two prim*ry vuln*r**l*