Permissions and a Sandbox¶
What you build¶
In exercise/guard.py:
decide: allow / ask / deny rules where any matching deny wins, regardless of rule ordercheck_write: a path guard that refuses../escapes, absolute paths, symlinks out of the workspace, protected files and non-writable folders, and tells the agent where it may writescrub_env: the child environment built from an allow-list, never a deny-listtrifecta_report: flags the lethal trifecta
In sandbox/: a Dockerfile and run-in-sandbox.sh, which runs one command with the network off, one mounted workspace, a non-root user, all capabilities dropped and resource limits.
Why it matters¶
Rules steer normal behavior. Boundaries hold when rules miss. One test, test_rules_are_tripwires_not_walls, passes precisely because a deny rule on git push* does not catch git -C . push. Read it twice.
Steps¶
- Implement the four functions;
python -m pytest -quntil all pass. - With Docker:
docker build -t harness-sandbox:latest sandbox/, thensandbox/run-in-sandbox.sh ../../examples/habit-tracker "python -m pytest -q". - Prove the boundaries: run
curl https://example.comandtouch /etc/xthrough the script and confirm both fail. - Fill in the threat model for an agent you use.
Done when¶
- All five tests pass.
- You can name which boundary stops each of: a secret leaking over the network, a write to
~/.ssh, a fork bomb.
Stretch goals¶
- Add an egress allow-list with a proxy container instead of
--network none. - Wire
check_writeinto Project 1's file tool.