Wire capability-gated broker mediation into the process backend#277
Merged
Conversation
The process backend denied every guest `request(...)` call with a flat "not available for the process backend" error, so a process-backend guest had no path to mediated privileged operations -- even though the threat model lists "broker-mediated privileged operations" as a defended layer for that mode. Mirror the sub-interpreter backend's semantics: - child.py: `request(capability, action, payload)` is gated on the granted capability names. An ungranted capability raises PolicyError at the boundary; a granted one is framed to the supervisor as an "ev": "request" message. The guest never performs the privileged action itself. - process_backend.py: the granted capability names are sent in the bootstrap frame, and an incoming request frame is surfaced via recv() as a BrokerRequest -- the same object the sub-interpreter backend emits -- so the supervisor mediates the action. Only capability names cross the boundary, never secrets. - supervisor.py: thread `capabilities` through spawn -> _spawn_process -> ProcessSandbox (previously dropped for this backend). SECURITY.md and the threat model are updated; the latter's history notes this makes the broker-mediation layer real for the process backend. Full suite: 494 passed, 6 skipped. black/isort/flake8/mypy clean; pylint 9.16. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PbbJc7Ntj159D9LNGevwC2
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
The threat model lists "broker-mediated privileged operations" as a defended layer for
backend="process", but the implementation didn't match:child.py'srequest()denied every call with a flat "not available for the process backend" error, andcapabilitieswere dropped entirely on the way to the process backend. So a process-backend guest had no path to mediated privileged operations at all.This reconciles reality with the model by mirroring the sub-interpreter backend's semantics.
Changes
child.py—request(capability, action, payload)is now gated on the granted capability names. An ungranted capability raisesPolicyErrorat the boundary; a granted one is framed to the supervisor as an"ev": "request"message. The guest never performs the privileged action itself.process_backend.py— the granted capability names are sent in the bootstrap frame, and an incomingrequestframe is surfaced viarecv()as aBrokerRequest— the same object the sub-interpreter backend emits — so the supervisor mediates the action. Only capability names cross the boundary, never secret material.supervisor.py— threadscapabilitiesthroughspawn→_spawn_process→ProcessSandbox(previously dropped for this backend).Semantics (matches the thread backend)
request("network", "connect", {...})BrokerRequest(capability="network", action="connect", payload={...})viarecv()request("secret", "read", {})PolicyErrorraised at the boundaryDocs & tests
SECURITY.md(§3.1) and the threat model are updated; the threat model's history notes this makes the broker-mediation layer real for the process backend. New tests cover the granted path (payload round-trips as aBrokerRequest), the ungranted-with-no-capabilities path, and the ungranted-but-other-capabilities-present path.Full suite: 494 passed, 6 skipped. black/isort/flake8/mypy clean; pylint 9.16 (gate 8.0).
🤖 Generated with Claude Code
Generated by Claude Code