Repository navigation
fix(sandbox): isolate role-required sandboxes per guest, not per agent - #130229
Conversation
Role-forced sandboxing (#129926) contained a guest against the Gateway host but not against other guests. Sandbox identity stayed agent-scoped, so every session on a shared agent converged on one scope key, container and workspace; configured workspaceAccess "rw" additionally pinned the workspace to the shared agent directory regardless of scope, and configured scope "shared" used a literal shared container name. Measured before the fix, two guests on one shared agent: scope=agent(default) rw -> same scope key, same workspace scope=agent(default) ro -> same scope key, same workspace scope=session rw -> distinct keys but SAME workspace scope=session ro -> isolated So only one of four combinations isolated guests, and it was not the default. The authorization layer promised "edit only your own sessions" while the container layer handed every guest the same writable workspace. Role-required sessions now derive their sandbox identity from the session creator: the scope key is principal-qualified, so different guests never share a container or workspace while one guest's own sessions still do (per guest, not per session). Configured "rw" resolves to "ro" with an operator-visible warning, configured "shared" resolves to an effective agent scope, and a required session with no creator provenance fails closed before provisioning. Sessions without the requirement keep today's behavior.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 26, 2026, 1:21 PM ET / 17:21 UTC. ClawSweeper reviewWhat this changesThe PR keys role-required sandbox containers and workspaces to the persisted authenticated creator, forces an effective agent scope, caps configured writable access to read-only, and updates diagnostics and docs. Merge readiness⛔ Blocked until real behavior proof is added - 8 items remain Keep open: the principal-qualified scope fixes the shared-container identity, but it silently turns configured guest write access into read-only access and disables editing. Final-effect isolation proof is also still needed. Likely related people: steipete (high-confidence feature owner). Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherGateway role policy stamps a sandbox requirement on a session created by an authenticated person. The agent sandbox layer reads that stored requirement to choose a runtime identity, workspace mounts, and tool access before provisioning a backend. flowchart LR
A[Authenticated creator] --> B[Session creation]
B --> C[Stored sandbox requirement]
C --> D[Sandbox runtime resolver]
D --> E[Principal-scoped identity]
E --> F[Workspace and backend provisioning]
F --> G[Guest tool access]
Decision needed
Why: The PR deliberately trades away an existing writable workflow to preserve isolation; choosing whether that loss is acceptable is a security and product-boundary decision. Before merge
Findings
Agent review detailsSecurityNeeds attention: The patch changes a principal-to-workspace security boundary without final-effect proof that a second guest is rejected before I/O. PR surfaceSource +62, Tests +267, Docs +25. Total +354 across 13 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the shared agent workspace read-only while making the creator-scoped sandbox workspace writable when the operator configured rw, then prove guest A can write only its own workspace and guest B cannot access it. Do we have a high-confidence way to reproduce the issue? Yes—source inspection gives a high-confidence path: a role-required session with configured workspaceAccess: rw is resolved to ro, which disables its write tools. Is this the best way to solve the issue? No. Principal-scoped identity solves the collision, but capping rw to ro removes the configured write workflow instead of providing a private writable workspace. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 447895981826. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
openclaw#130229) * fix(sandbox): isolate role-required sandboxes per guest, not per agent Role-forced sandboxing (openclaw#129926) contained a guest against the Gateway host but not against other guests. Sandbox identity stayed agent-scoped, so every session on a shared agent converged on one scope key, container and workspace; configured workspaceAccess "rw" additionally pinned the workspace to the shared agent directory regardless of scope, and configured scope "shared" used a literal shared container name. Measured before the fix, two guests on one shared agent: scope=agent(default) rw -> same scope key, same workspace scope=agent(default) ro -> same scope key, same workspace scope=session rw -> distinct keys but SAME workspace scope=session ro -> isolated So only one of four combinations isolated guests, and it was not the default. The authorization layer promised "edit only your own sessions" while the container layer handed every guest the same writable workspace. Role-required sessions now derive their sandbox identity from the session creator: the scope key is principal-qualified, so different guests never share a container or workspace while one guest's own sessions still do (per guest, not per session). Configured "rw" resolves to "ro" with an operator-visible warning, configured "shared" resolves to an effective agent scope, and a required session with no creator provenance fails closed before provisioning. Sessions without the requirement keep today's behavior. * chore: drop accidentally committed sandbox scope repro scratch file
What Problem This Solves
Role-forced sandboxing (#129926) contained an untrusted guest against the Gateway host, but not against other guests.
Sandbox identity stayed agent-scoped, so on a shared agent every session collapsed onto one scope key — one container, one workspace. Two independent amplifiers made it worse:
workspaceAccess: "rw"pinned the workspace to the shared agent directory regardless of scope, andscope: "shared"used a literal shared container name.Measured before the fix, two guests on one shared agent (
resolveSandboxWorkspaceLayoutPaths):Only one of four combinations isolated guests, and it was not the default. The authorization layer promised "edit only your own sessions" while the container layer handed every guest the same writable workspace — guest A could read and modify guest B's work.
Why This Change Was Made
A role-forced sandbox exists to contain an untrusted principal. Sharing a runtime or a writable workspace between principals defeats that, so isolation must be keyed to the principal rather than to the agent.
Role-required sessions now derive sandbox identity from the session creator (
createdActor.id, already persisted): the scope key is principal-qualified. Different guests never share a container or workspace; one guest's own sessions still do — per guest, not per session, which avoids spawning a container per session while still isolating tenants.Three supporting cuts, all scoped to role-required sessions only:
workspaceAccess: "rw"resolves to"ro"with an operator-visible warning (otherwise the workspace is pinned to the shared agent directory and principal keying is silently defeated);scope: "shared"resolves to an effective agent scope, so the principal-qualified key actually reaches the container name;Sessions without the requirement — maintainers, and every roles-off deployment — keep today's behavior exactly.
User Impact
scope: "agent") is corrected automatically for role-required sessions.rwdowngrade is surfaced, not silent — a security downgrade nobody can see is how this class of bug survives.createdActoralready exists on the entry.Evidence
Independent re-derivation of the layout (not the worker's report), across all three configured scopes:
{"scope":"agent", "sameGuest_sharesContainer":true,"differentGuests_isolated":true} {"scope":"session","sameGuest_sharesContainer":true,"differentGuests_isolated":true} {"scope":"shared", "sameGuest_sharesContainer":true,"differentGuests_isolated":true}Unstamped sessions keep byte-identical scope keys to current
main(verified in the same run), so maintainer behavior is provably unchanged.Regressions (each observed failing pre-fix): different guests get distinct scope key/container/workspace across
agent,sessionandshared; same guest reuses one across all three; persisted creator identity propagates andrwresolves toro; unstamped sessions retain writable access and gain no guest-specific fields; provisioning convertsshared→effective agent scope, caps access, uses a private workspace and emits the warning; required session without creator provenance fails closed; plugin-facing workspace authority reportsroand refuses to certify a principal-shared sandbox as session-exclusive.Validation: 131 tests across 11 files;
CI=true pnpm check:changedgreen; fresh$autoreviewclean (0.95).LOC: production +75/−13 (net +62), tests +277/−10, docs +25.
Found while security-auditing #129926 rather than reported from production.