fix(python): shallow-copy OSAccess environ to prevent host dict aliasing#1
Draft
tusharhqq wants to merge 1 commit into
Draft
fix(python): shallow-copy OSAccess environ to prevent host dict aliasing#1tusharhqq wants to merge 1 commit into
tusharhqq wants to merge 1 commit into
Conversation
OSAccess now stores a shallow copy of the environ mapping at construction so callers cannot accidentally pass os.environ or a shared dict and have post-init mutations widen what Monty sees. Adds regression tests and extends the Hackmonty threat map with host OSAccess/environ wiring notes. Co-authored-by: Tushar Dahiya <tushardzig@gmail.com>
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 23559 uncovered lines. Generated by Codecov Action |
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
OSAccesspreviously stored theenvironmapping by reference (environ or {}), which made it easy for host code to accidentally passos.environor another shared dict and have post-construction mutations change what Monty observes. That matches the failure mode described in the Hack Monty bounty updates (wrapper misuse aroundOSAccess(environ=...)rather than a VM escape).Changes
dict(environ)whenenviron is not None, otherwise{}.__init__docstrings.OSAccess(environ=os.environ)must not keep a live alias to the process environment.challenge/HACKMONTY_BOUNDARY_THREAT_MAP.mdwith a host-sideOSAccess/environwiring section.Testing
Python tests were not executed in this agent environment (workspace Cargo is 1.83.0;
maturin developrequires edition 2024). Please runmake test-pyor the targetedpytestcases locally.