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:
25 files changed
+444
-29
No files matched your search
@@ -91,3 +91,32 @@ teardown() {
|
||||
echo "status: $status"
|
||||
assert_output "false"
|
||||
}
|
||||
|
||||
@test "(common) fn-docker-args-split does not expand injected commands" {
|
||||
export DOKKU_TEST_PAYLOAD='--label x=$(id)'
|
||||
run /bin/bash -c "source '$PLUGIN_CORE_AVAILABLE_PATH/common/functions'; fn-docker-args-split \"\$DOKKU_TEST_PAYLOAD\" | tr '\\0' '\\n'"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_line 1 'x=$(id)'
|
||||
[[ "$output" != *"uid="* ]] || flunk "id command output leaked - value was expanded"
|
||||
|
||||
export DOKKU_TEST_PAYLOAD='--label x=`id`'
|
||||
run /bin/bash -c "source '$PLUGIN_CORE_AVAILABLE_PATH/common/functions'; fn-docker-args-split \"\$DOKKU_TEST_PAYLOAD\" | tr '\\0' '\\n'"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_line 1 'x=`id`'
|
||||
[[ "$output" != *"uid="* ]] || flunk "id command output leaked - value was expanded"
|
||||
|
||||
unset DOKKU_TEST_PAYLOAD
|
||||
}
|
||||
|
||||
@test "(common) fn-docker-args-split preserves quoted tokens" {
|
||||
run /bin/bash -c "source '$PLUGIN_CORE_AVAILABLE_PATH/common/functions'; fn-docker-args-split \"--label 'a b'\" | tr '\\0' '\\n'"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_line 0 "--label"
|
||||
assert_line 1 "a b"
|
||||
}
|
||||
Reference in new issue
Block a user