Summary
A command injection vulnerability in Dokku's cron plugin allows crafted app.json cron commands with shell metacharacters to escape the Docker container boundary.
When an attacker can control these cron command definitions, they may execute arbitrary commands on the host as the Dokku user, creating a critical privilege risk.
Affected context
This vulnerability occurs in Dokku deployments that use the cron plugin to schedule tasks defined via app.json.
The risk appears when app.json cron commands are treated as shell strings and executed without sufficient sanitization or isolation, allowing shell metacharacters such as > or ; to alter the intended command.
Any environment where application owners or automated systems can modify app.json commands, and where those commands ultimately run on the host under the Dokku user, may be affected.
Exploit preconditions
- Attack surface: Dokku application configuration, specifically the cron commands defined in app.json.
- Required access: Ability to modify or deploy an app.json file for a Dokku application (e.g., application maintainer, CI pipeline, or compromised developer account).
- Trigger point: Execution of the cron plugin's scheduled job, which reads and runs the configured app.json command.
- Why exploitation is possible: The cron plugin constructs and executes shell commands derived directly from app.json input, allowing shell metacharacters to inject additional commands that run on the host as the Dokku user and bypass the container boundary.
Why this happens
The root cause aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command.
Dokku's cron plugin treats user-controlled strings from app.json as shell commands, concatenating or passing them directly to a shell interpreter without proper escaping, validation, or use of safer APIs.
Because the shell is invoked with an unsanitized command string, metacharacters such as >, ;, &&, and similar constructs can change the execution flow, enabling additional commands to run outside the intended container scope.
Abstractly, this is an insecure pattern where configuration-driven commands are built dynamically and executed by a shell, rather than using parameterized, constrained execution primitives.
Potential impact
- Host-level command execution as the Dokku user.
- Modification or deletion of application data and configuration on the host.
- Abuse of cron to establish persistence or scheduled malicious tasks.
- Lateral movement to other containers or services using accessible credentials or sockets.
- Interference with deployment pipelines and service availability.
General mitigation guidance
Effective mitigation focuses on limiting shell exposure and reducing trust in configuration-driven commands.
Recommended patterns include:
- Avoid passing configuration strings directly to a shell; use APIs that execute commands with explicit argument lists and no shell parsing.
- Constrain allowed cron commands to a fixed set of templates or whitelisted binaries and arguments, rather than arbitrary user-defined shell snippets.
- Apply strict validation on app.json cron fields, rejecting metacharacters, redirection operators, and other shell control tokens.
- Run cron-related processes and Dokku services with least privilege, restricting file system and network access where feasible.
- Separate configuration-authoring responsibilities from sensitive runtime execution, and treat application configuration as potentially untrusted input.
How teams detect issues like this
Detection can rely on a mix of configuration review and code-level analysis:
- Static analysis or linting rules that flag dynamic shell execution patterns (e.g.,
sh -c,system,execwith concatenated strings) within plugin code. - Policy-based checks in CI/CD that inspect app.json files for forbidden shell metacharacters in cron definitions.
- Regular code reviews focused on configuration-driven execution paths, especially where user input influences OS command construction.
- Host and container monitoring for anomalous cron activity, unexpected commands run by the Dokku user, and unusual file or process modifications.
- Use of automated security scanners that highlight CWE-78 patterns and shell injection risks in infrastructure automation scripts and plugins.

