Summary
Dokku's app name validation previously allowed shell metacharacters that were later embedded unquoted into a Bash pre-receive hook.
An authenticated user who can push to a Dokku git remote can craft an app name that injects additional commands, resulting in arbitrary command execution as the dokku user during git push.
Affected context
This vulnerability occurs in Dokku deployments that accept application creation and git pushes from authenticated users.
It manifests when app names containing shell metacharacters are accepted by validation logic and then interpolated directly into Bash hook scripts via an unquoted heredoc.
The risk is present in environments where the dokku user has meaningful access to system resources or controls production applications.
Exploit preconditions
- Attack surface: Git remote interface exposed by Dokku
- Required access: Authenticated access capable of creating apps and pushing to the Dokku git remote
- Trigger point: Execution of the Bash pre-receive hook during
git pushfor a crafted app name - Why exploitation is possible: The app name is embedded unquoted into a shell script via an unquoted heredoc; shell metacharacters in the name are interpreted as command separators and executed
Why this happens
The root cause is improper neutralization of special elements in shell commands (CWE-78).
Application names supplied by users are only lightly validated by a regex that still permits shell metacharacters and are then written directly into a Bash script without quoting or escaping.
When the pre-receive hook runs, Bash parses these untrusted values as part of its command stream, allowing attackers to inject additional commands.
Abstractly, this reflects a pattern where user-controlled identifiers are treated as safe and embedded into shell constructs without strict sanitization or isolation.
Potential impact
- Authenticated users may execute arbitrary commands as the dokku user
- Attackers could manipulate deployed applications or their configuration
- Sensitive data accessible to the dokku user could be read or modified
- Hosts running Dokku could be further compromised through privilege escalation or lateral movement
General mitigation guidance
Mitigation focuses on separating untrusted data from shell interpretation boundaries and tightening validation of identifiers.
Recommended patterns include:
- Applying strict allowlist-based validation for app names, limiting characters to a safe subset that cannot alter shell syntax
- Ensuring all user-supplied values embedded into shell scripts are properly quoted or escaped, or avoiding direct shell composition entirely
- Refactoring operational tooling to use safer APIs (e.g., direct exec calls or configuration files) instead of dynamically generated shell scripts
- Running Dokku and related automation under least-privilege accounts to reduce impact if command execution occurs
How teams detect issues like this
Detection commonly involves:
- Static analysis and linting rules that flag unquoted use of variables or heredocs in shell scripts and templates
- Code review practices that scrutinize any interpolation of user-controlled values into command lines or hooks
- Policy-based checks in CI pipelines to enforce safe patterns for regex validation and shell interaction
- Runtime monitoring of Dokku environments for unusual commands executed by the dokku user or anomalous activity after git pushes

