Repository navigation
fix: policy denies python -m — the cwd lands on sys.path - #40
Merged
Merged
Conversation
python -m executes a module by name with the CURRENT DIRECTORY at sys.path[0]: 'python3 -m evil' imports and runs /workspace/evil.py — guest-written code under the trusted python3 name. Denied for python/python3 (version-tolerant) wherever python appears, including cluster forms (-Bm). Legitimate module runs (python3 -m http.server) pay the same price — documented; script-file form (python3 script.py) stays allowed, and operators who need -m have exec.allowlist.
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
Part 6 of 18 in the exec-denylist fix series.
python -m <module>executes a module by name with the current directory atsys.path[0]— and the child's cwd is the guest-writable workspace.python3 -m evilimports and runs/workspace/evil.py: guest-written code under the trustedpython3name, invisible to the shell/interpreter gates.python/python3(version-tolerant) wherever python appears, including bundled short-flag clusters (-Bm)python3 -m http.server) pay the same price — the module name is argv-visible but trusted-vs-guest resolution (site-packages vs cwd) is not something the v0 denylist can scope. Script-file form (python3 script.py) stays allowed; operators who need-mhaveexec.allowlist.grep -m 5 …(an-mdata flag without python) stays allowedTest plan
python_module_exec_is_denied: 8 assertions (path tolerance, version tolerance, rest-reach, cluster form, allow side, false-positive guard)cargo test -p toolcage-policy: 39 passedcargo test --workspace: 51 suites, 0 failed-D warnings: clean