Summary
Before version 0.31.1, Dokploy's Nixpacks publishDirectory build setting could pass shell metacharacters into a command executed through child_process.exec. An authenticated user with access to an application could trigger a deployment that runs arbitrary commands on the Dokploy host, potentially compromising the host through its privileged Docker environment.
Affected context
The issue affects Dokploy deployments that use the Nixpacks build process and construct a docker cp command using the publishDirectory setting. It becomes risky when an authenticated user can influence that setting and a deployment executes the resulting shell command.
Exploit preconditions
- Attack surface: Nixpacks application deployment
- Required access: Authenticated access to an application with the ability to influence its build settings and trigger deployment
- Trigger point: Execution of the
docker cpcommand during a Nixpacks deployment - Why exploitation is possible: Shell metacharacters in
publishDirectoryare interpolated into a command executed throughchild_process.exec, allowing shell interpretation
Why this happens
The underlying issue is OS command injection, mapped to CWE-78. Building a shell command by interpolating a user-influenced setting allows shell syntax in that value to be interpreted as part of the command rather than as data. The command runs in a privileged Docker environment, increasing the potential consequences.
Potential impact
- An attacker could execute arbitrary commands on the Dokploy host.
- The host and its deployment environment may be compromised.
- Access to the privileged Docker environment could enable further impact on workloads or data.
General mitigation guidance
Defensive patterns focus on avoiding shell interpretation and limiting the trust placed in build settings:
- Prefer process APIs that pass executable arguments as an array rather than constructing shell command strings.
- Treat build configuration as untrusted; validate values against a narrow, appropriate format.
- Avoid accepting arbitrary paths where a constrained set of directories or identifiers will suffice.
- Run deployment and Docker-related processes with the least privilege and access necessary.
- Apply isolation and policy controls so that compromise of a build process does not grant broad host access.
How teams detect issues like this
- Use static analysis to identify shell-execution APIs such as
child_process.execand trace whether user-controlled values reach command strings. - Review code for string interpolation in commands, especially for build settings and file paths.
- Enforce code-review or CI policies that prefer argument-based process APIs and require validation of configuration values.
- Monitor deployment activity and host processes for unexpected command execution associated with Nixpacks builds.

