fix(agent-sandbox): enforce the session ring in HyperLightSandboxProvider.execute_code #4570
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #4570"
general
weight: 0.35
MohammadHaroonAbuomar
Related Issue
Fixes #4569
Problem & Solution
Problem:
execute_codereads the session's ring from the stored session config to run the ring subprocess gate and record the call with theRingBreachDetector. Docker and ACA store theSandboxConfig, which has aringfield.HyperLightSandboxProviderstores theHyperlightConfig, which had none, sogetattr(cfg, 'ring', None)was alwaysNoneand the gate was skipped. A Hyperlight session created withSandboxConfig(ring=RING_3_SANDBOX)ran code that Docker and ACA refuse for the same config, no call was recorded for breach detection, and a tripped circuit breaker blocked nothing.Solution:
HyperlightConfiggets aringfield andfrom_sandbox_configcarriesSandboxConfig.ringover. The gate inexecute_codeis unchanged; it now finds the ring it was already looking for.Behaviour note: with
agent-hypervisorinstalled, a Hyperlight session pinned to a ring that denies subprocess execution (Ring 3) now raisesPermissionErroronexecute_code, as Docker and ACA already do. Sessions created without a ring, or withoutagent-hypervisorinstalled, are unchanged.Impact on Your Work
Found while reviewing the sandbox providers. Anyone who pinned a Hyperlight session to an execution ring got weaker enforcement than the same config gives on Docker or ACA, with no warning.
Timeline
None
Alternatives Considered
_ring_enforcersand_ring_breach_detectors, while the other providers read it from the session config.SandboxConfignext to theHyperlightConfig: more state for one field.Type of Change
Behaviour note:
execute_codenow raises for ring-pinned Hyperlight sessions in the cases where Docker and ACA already raise.Package(s) Affected
Governance & security:
Shared / other:
CHANGELOG.md)Testing
Unit Testing
In
agent-governance-python/agent-sandbox/tests/test_ring_enforcement_wiring.py, added toTestHyperlightRingEnforcement:test_session_config_keeps_ring:HyperlightConfig.from_sandbox_configcarries the ring over, and leaves itNonewhen unset.test_execute_code_ring3_subprocess_denied: a Ring 3 session raisesPermissionError, the guest is never run, and the breach detector records the call.test_circuit_breaker_tripped_blocks_execute: a tripped breaker blocks a Ring 2 session before the guest runs.test_execute_code_ring2_permitted: a Ring 2 session runs and the call is recorded.test_execute_code_ring_none_is_noop: no ring, no gate, no ring state.The sessions are created through
create_sessionand nothing is injected into the provider afterwards, so the tests depend on the ring reachingexecute_code. The first four fail onmainand pass with this change.Manual Testing
pytest tests/test_ring_enforcement_wiring.py: 18 passed.agent-sandboxsuite with the in-repoagent-control-specification0.4.0b0 andagent-hypervisoron the path, excludingtests/test_docker_integration.py: 545 passed, 37 skipped, 0 failed (540 passed onmain).tests/test_docker_integration.pyerrors onmainwhen a Docker daemon is running (ModuleNotFoundError: No module named 'agent_sandbox.docker_sandbox_provider'); unrelated and not touched here.hypervisor.ringsclasses and a stub SDK injected throughsandbox_module=: onmain, a Ring 3 Hyperlight session executes the code and the breach detector records 0 calls, while Docker denies and records 1; on this branch Hyperlight denies with the same error as Docker, records 1 call, and no code reaches the guest.ruff checkon the touched files: clean.hyperlight-sandboxinstall or hypervisor; verified with stubbed SDKs only.Checklist
Attribution & Prior Art
Prior art / related projects (if any):
AI Assistance
If AI tools materially shaped this change, briefly note what was used:
Claude Code was used to survey the sandbox package, draft the fix and tests, and draft this description.
IP, Patents, and Licensing