T09 · Insecure Skill Coding Practices
- Location
scripts/dokploy-config.sh:31- Finding
Shell Command Injection Through Executable Configuration File Generation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/dokploy-config.sh:31-38
Vulnerability Type: Persistent shell command injection
Risk Level: HighVulnerable Code
bash # Save to config file mkdir -p "$(dirname "$CONFIG_FILE")" cat > "$CONFIG_FILE" << EOF export DOKPLOY_API_URL="${DOKPLOY_API_URL}" export DOKPLOY_API_KEY="${DOKPLOY_API_KEY}" EOF log_success "Config saved to $CONFIG_FILE" log_info "Run: source $CONFIG_FILE to load"Technical Analysis
User-controlled values supplied through
--urland--keyare inserted directly into an executable shell file. The values are not escaped or validated for quotation marks, newlines, command substitutions, or other shell syntax.Expansion while generating the file does not safely encode the resulting value. An input containing a closing quotation mark and a newline can terminate the intended
exportstatement and add arbitrary shell commands. The script then explicitly directs the user to execute the generated file withsource.For example, a malicious URL value can cause the generated file to contain:
bash export DOKPLOY_API_URL="https://example.invalid" attacker_command #"This is persistent until
~/.dokployrcis replaced and executes in the context of every shell that subsequently sources the file.Attack Path
- An attacker supplies or recommends a crafted
--urlor--keyvalue containing quotation marks, a newline, and a shell command. - The user or Agent runs
dokploy-config setwith that value. - The script writes the attacker-controlled shell syntax to
~/.dokployrc. - The user follows the displayed instruction and runs
source ~/.dokployrc, or sources it later from another shell initialization workflow. - The injected command executes with the privileges of that user.
Impact Assessment
Successful exploitation permits arbitrary command execution under the account running the Skil ...[truncated 331 chars]
- An attacker supplies or recommends a crafted
- Remediation
View remediation
Remediation Suggestions
- Do not store configuration in an executable shell file.
- Use a non-executable data format such as JSON and parse it with
jq. - Validate the API URL with an explicit scheme and host policy.
- Reject carriage returns, newlines, null bytes, and other control characters in configuration values.
- If shell-format output is unavoidable, encode values with a shell-safe mechanism such as
printf '%q'and test round-trip behavior. - Remove instructions that encourage sourcing attacker-influenced files.
- Replace existing configuration files atomically after validating all inputs.
