fix: prevent command injection via docker options eval

Values supplied through docker options, `--ttl-seconds`, and `-e` flowed into a Bash `eval` during build, deploy, and run, letting a low-privileged user execute arbitrary commands on the host as the dokku user. These arguments are now tokenized and passed through to the container verbatim, without shell expansion. A one-time migration repairs stored labels whose backticks were saved with a stray backslash so Traefik-style rules stay valid on the next deploy.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-07-19 01:42:12 -04:00
1 parent 730fa85d03
commit 1a376c3622
25 files changed
+444 -29

No files matched your search

+19
View File
@@ -285,6 +285,25 @@ teardown() {
assert_output "/tmp:{} /var/tmp:{}"
}
@test "(docker-options) deploy does not expand command substitution in option values [buildpacks]" {
run /bin/bash -c "dokku docker-options:add $TEST_APP deploy '--label=com.dokku.test=\$(id)'"
echo "output: $output"
echo "status: $status"
assert_success
run deploy_app
echo "output: $output"
echo "status: $status"
assert_success
CID=$(<$DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
run /bin/bash -c "docker inspect $CID --format '{{ index .Config.Labels \"com.dokku.test\" }}'"
echo "output: $output"
echo "status: $status"
assert_output '$(id)'
[[ "$output" != *"uid="* ]] || flunk "id command output leaked - option value was expanded"
}
@test "(docker-options) deploy with options [dockerfile]" {
run /bin/bash -c "dokku docker-options:add $TEST_APP deploy \"-v /var/tmp\""
echo "output: $output"