fix(autogen-ext): enforce trust boundary on Docker volume mounts (OWASP ASI10) - #8245
Draft
maxpetrusenkoagent wants to merge 1 commit into
Draft
maxpetrusenkoagent wants to merge 1 commit into
maxpetrusenkoagent wants to merge 1 commit into
Conversation
…SP ASI10)
The Docker code executor previously mounted arbitrary host paths supplied via
extra_volumes without validating them against any trust boundary. This is a
container escape vector (OWASP Agentic Security Initiative, ASI10): an agent
with code execution could read or write host files such as /etc/passwd or
/var/run/docker.sock simply by passing a path through extra_volumes.
Add _validate_host_volume_paths() which is invoked at the start of start()
before any Docker client connection is made. The validator:
* allowlists paths under the executor's own work_dir / bind_dir
* rejects absolute paths resolving to well-known sensitive directories
* rejects relative paths or traversal that escape the workspace
* rejects empty paths, NUL-byte injections, and non-dict bind specs
* requires absolute paths outside the sensitive block to exist on the host
so typos in extra_volumes surface immediately
The change is fail-closed: any path the executor cannot reason about is
rejected. Default behavior is now safe; existing callers that pass paths
under work_dir/bind_dir continue to work unchanged.
Adds tests/code_executors/docker/test_docker_security_validation.py covering
sensitive paths, Docker socket, traversal, relative paths, empty strings,
invalid mount specs, and the workspace allowlist happy path.
Fixes microsoft#7917
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #7917 (OWASP ASI10: Docker code executor mounts host filesystem without trust boundary validation).
DockerCommandLineCodeExecutor.start()accepted arbitrary host paths viaextra_volumeswithout validating them. An agent with code-execution capability could escape the container sandbox simply by mounting/etc/passwd,/var/run/docker.sock, or any sensitive path on the host. This is the trust-boundary violation that OWASP flags as ASI10.Changes
python/packages/autogen-ext/src/autogen_ext/code_executors/docker/_docker_code_executor.pyAdds
_validate_host_volume_paths()and calls it at the start ofstart()before any Docker client connection is attempted (fail-closed). The validator:work_dir/bind_dirso the default sandbox workflow keeps working unchanged./etc,/root,/home,/var,/usr,/proc,/sys,/var/run/docker.sock, etc.). The list is resolved against the host at import time, so/etcis correctly caught on macOS where it symlinks to/private/etc...that escape the workspace roots.python/packages/autogen-ext/tests/code_executors/docker/test_docker_security_validation.py(new)Seven unit tests using a mocked
docker.from_envso they do not require a running Docker daemon:test_sensitive_host_path_is_rejected—/etc/passwdis blocked.test_docker_socket_is_rejected—/var/run/docker.sockis blocked.test_path_traversal_is_rejected—../../etc/passwdis blocked.test_relative_path_outside_workspace_is_rejected— relative paths escape attempts are blocked.test_workspace_path_is_allowed— paths insidework_dircontinue to work.test_empty_path_is_rejected— empty host source path is blocked.test_invalid_mount_spec_is_rejected— non-dict bind specifications are blocked.Verification
Lint:
ruff checkon both touched files — All checks passed.Test plan
tests/code_executors/test_docker_commandline_code_executor.pycontinue to pass with a real Docker daemon.Notes
This is a fail-closed security fix. Any caller that previously relied on mounting sensitive paths outside
work_dir/bind_dirwill now see a clearValueErrorexplaining why the mount is refused and how to remediate.Fixes #7917