Summary
Dokploy's backup and restore pipeline constructs shell commands by directly embedding user-controlled database fields into shell command strings. An authenticated administrator or owner may exploit this behavior to execute arbitrary operating-system commands on the host running Dokploy, rather than only within an application container.
Affected context
This vulnerability affects Dokploy deployments whose backup or restore workflows build shell commands from database-controlled values and execute those commands through shell-enabled process APIs. Exploitation generally depends on an authenticated user having administrator or owner privileges and on the affected workflow processing attacker-influenced fields.
Exploit preconditions
- Attack surface: Dokploy backup and restore functionality
- Required access: Authenticated administrator or owner access, or another capability that permits influencing the relevant database fields
- Trigger point: Execution of a backup or restore operation that incorporates the stored values into a shell command
- Why exploitation is possible: User-controlled data is interpolated into
bash -corsh -ccommand strings before execution through a child-process API, allowing shell metacharacters and additional commands to be interpreted by the host shell
Why this happens
The underlying bug is command construction through string interpolation followed by shell interpretation. Rather than treating database values as inert arguments, the application combines them with shell command text and passes the result to a shell-enabled execution function.
This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, commonly known as OS command injection. The insecure pattern occurs when data that may be influenced by users crosses into an operating-system command interpreter without robust separation from command syntax.
Potential impact
- An attacker may execute arbitrary commands with the privileges of the Dokploy service
- The host operating system could be compromised
- Application secrets, credentials, and deployment data may be exposed
- Managed applications or infrastructure could be modified, disrupted, or deleted
- The compromised host could be used for lateral movement or persistence
- Backups and restored data could be tampered with
General mitigation guidance
Mitigation generally focuses on eliminating shell interpretation and reducing trust in values used by backup and restore workflows.
Common defensive patterns include:
- Prefer direct process APIs that accept an executable and an argument array rather than a shell command string
- Avoid passing user-controlled values to
bash -c,sh -c, or equivalent shell interpreters - Apply strict allowlists and type validation to fields that select files, databases, hosts, or operations
- Use canonicalized, application-managed identifiers instead of accepting arbitrary command fragments or paths
- Separate command construction from data handling and enforce validation before invoking external processes
- Run backup and restore workers with the minimum host and filesystem privileges required
- Restrict access to administrative workflows and protect stored configuration and database fields from unauthorized modification
- Use isolation boundaries where feasible, while recognizing that container isolation alone does not address host-level command execution
How teams detect issues like this
High-level detection can combine source review, runtime monitoring, and policy enforcement:
- Use static analysis rules to identify shell-enabled process execution, including
exec()calls and uses ofbash -corsh -c - Search for string concatenation, interpolation, or template construction involving database fields near process-spawning APIs
- Review backup and restore code for values that represent paths, filenames, connection parameters, or command options
- Add code-review checks requiring argument-array process APIs and documented validation for external-process inputs
- Monitor host process creation from Dokploy services and alert on unexpected shells, interpreters, or administrative utilities
- Record and review privileged backup and restore activity, including the initiating identity and affected resources
- Enforce application security policies that prohibit unsanitized user or database data from reaching shell interpreters
- Automated code-review and software-composition tools may help identify common command-injection patterns, but should be supplemented with manual review

