Summary
A shell command injection vulnerability in Dokku's openresty-vhosts plugin allows crafted filenames from an app's git repository to be interpolated into an eval'd shell string without proper escaping.
If an attacker can create or control files under openresty/http-includes/ with filenames containing special characters, they can execute arbitrary commands on the host as the dokku user during the next application deployment.
Affected context
This vulnerability occurs in Dokku deployments that use the openresty-vhosts plugin and rely on files under an app's openresty/http-includes/ directory being copied and processed on the host during deployment.
The risk is present when filenames from that directory are interpolated directly into shell strings that are later executed, especially in environments where application maintainers or integrated processes can introduce untrusted or dynamically generated filenames.
Exploit preconditions
- Attack surface: Dokku deployment pipeline using the openresty-vhosts plugin
- Required access: Ability to create, rename, or modify files in the app's openresty/http-includes/ directory via the associated git repository or build process
- Trigger point: Application deployment, when the plugin copies files to the host and constructs shell strings containing their filenames
- Why exploitation is possible: Filenames are injected unescaped into a single-quoted shell string that is later parsed by eval, allowing special characters (e.g., single quotes and command substitution syntax) to break quoting and introduce attacker-controlled shell commands
Why this happens
The underlying issue maps to CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code ("eval injection").
The plugin builds a shell command by interpolating raw filenames into a single-quoted string and then passes that string to eval, effectively treating data as code.
Because user-controllable filenames are not sanitized or safely quoted, shell metacharacters embedded in the filename are interpreted by the shell, turning what should be passive data into executable directives.
Potential impact
- Arbitrary command execution on the Dokku host as the dokku user
- Modification or deletion of application code, configuration, or data managed by Dokku
- Unauthorized access to other applications running under the same Dokku instance
- Establishment of persistence mechanisms or backdoors on the host
- Potential lateral movement to other services, depending on the dokku user's privileges and network access
General mitigation guidance
Effective mitigation focuses on eliminating direct eval of dynamically constructed shell strings and separating data from executable code.
Common defensive patterns include:
- Avoiding eval entirely in deployment scripts and plugins, favoring explicit, parameterized commands
- Treating filenames and other user-influenced values as opaque data and passing them as separate, properly quoted arguments to shell commands
- Applying strict validation and normalization to filenames used in automation, rejecting or sanitizing characters that have special meaning to the shell
- Running deployment tooling with least-privilege accounts and minimizing what those accounts can access or modify on the host
- Designing plugins so that text processing and command construction are done with libraries or languages that reduce exposure to shell metacharacter parsing
How teams detect issues like this
High-level detection strategies for this vulnerability class typically involve a mix of static, review-based, and policy-driven controls:
- Static analysis rules that flag uses of eval, backticks, or complex shell expansions in deployment scripts and plugins, especially when combined with user-controllable input
- Code review practices that require reviewers to trace how filenames and other app-controlled values flow into shell commands, looking for missing quoting or sanitization
- Organizational policies that discourage or forbid eval-based logic in infrastructure automation, with automated checks to enforce these standards
- Periodic security audits of deployment pipelines and PaaS plugins to identify patterns where application data is used to construct shell code

