fix: avoid shell parsing in docker cleanup - #30506
Conversation
keegoid-codex
left a comment
There was a problem hiding this comment.
Bugs
- [CAT-1] Run
rm -fafter stop timeout; current exception path leaks containers attools/environments/docker.py:640.
Severity
- high. Cleanup leak preserves untrusted nonpersistent containers after Docker stop hangs.
Verdict
VERDICT: request_changes
codex-review posting override: forced to --comment because reviewer lacks verified write permission (viewerPermission=READ; was --request-changes). GitHub only counts approvals from WRITE, MAINTAIN, or ADMIN reviewers.
|
[DEV SecOps] verdict: PASS
|
|
Hey @PrAndrian, this is a clean security fix but unfortunately it's a duplicate of #29189 (same shell=True -> argv fix in DockerEnvironment.cleanup(), opened first). Appreciate the eye for shell injection vectors. Would love to see you tackle a fresh issue. |
|
Closing — duplicate of #29189 which is also open, mergeable, and applies the same Your version's regression test fixtures (shell-metacharacter container IDs like The underlying bug is still real (verified: |
What does this PR do?
This PR removes shell parsing from Docker container cleanup.
DockerEnvironment.cleanup()previously built shell command strings and ran them withshell=Trueto stop and remove containers. That made configured Docker binary paths and container IDs pass through a shell unnecessarily.This changes cleanup to use argv form subprocess calls instead:
docker stop --time 60 <container_id>docker rm -f <container_id>This is safer, clearer, and matches the rest of the Docker environment code style.
Related Issue
No issue opened.
Type of Change
Changes Made
tools/environments/docker.pysubprocess.run(...)shell=Trueusage from Docker cleanupdocker_exe,container_id, andpersistentbefore clearing_container_idtests/tools/test_docker_environment.pytests/tools/test_docker_environment_cleanup.pyshell=TrueHow to Test
git checkout fix/docker-cleanup-no-shellRun the targeted Docker environment tests:
Confirm the result: 35 passed
Checklist
Code
Documentation & Housekeeping
Screenshots / Logs
Targeted tests pass:
scripts/run_tests.sh tests/tools/test_docker_environment.py tests/tools/test_docker_find.py tests/tools/test_docker_environment_cleanup.py35 passed
Full suite was attempted but did not pass in this container environment:
scripts/run_tests.sh tests/
8 tests failed across 4 unrelated areas: