Repository navigation
fix(sandbox): authorize canonical destinations before pinned fs mutations - #143501
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 10, 2026, 10:56 PM ET / September 11, 2026, 02:56 UTC (Revision 10). ClawSweeper reviewWhat this changesThe PR checks sandbox filesystem mutations against their symlink-resolved destinations and carries those authorized destinations into local and remote filesystem operations. Merge readiness⛔ Blocked before merge - 1 item remains This security fix remains necessary: current main and the latest release still authorize mutations using lexical paths. No blocking patch defect remains, and the expanded legacy-bridge coverage resolves the previous compatibility-proof concern. Priority: P0 Review scores
Verification
How this fits togetherThe Codex sandbox exec-server receives filesystem requests and request-local access policies, then delegates operations to OpenClaw’s sandbox bridges. These bridges translate paths and execute guarded filesystem operations in local or remote workspaces. flowchart TD
A[Codex filesystem request] --> B[Resolve canonical destination]
B --> C[Check lexical and canonical policy paths]
C -->|Denied| D[Reject before mutation]
C -->|Allowed| E[Carry authorized destination]
E --> F[Local or remote no-follow operation]
F --> G[Filesystem result]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +456, Tests +899. Total +1355 across 12 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Bind authorization and mutation to the same canonical destination while preserving logical policy namespaces, legitimate aliases, and compatibility with existing bridges. Do we have a high-confidence way to reproduce the issue? Yes, source inspection establishes the path: current main authorizes a writable lexical alias before the bridge resolves its protected destination. This read-only review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes. Authorizing the canonical destination and consuming that exact pin repairs the mismatch at the policy-to-filesystem boundary; optional additions and legacy-bridge coverage preserve existing implementations. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d36ca99e50d1. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞👀 Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Merge recordSummary: Authorizes the canonical destination before every write-class sandbox filesystem mutation and pins the mutation to exactly that destination across the Codex exec-server handler and both shipped bridges. A symlinked ancestor (placed once or swapped mid-operation) could previously redirect an approved write into a policy-protected path such as Decision Reason for Merge: "Merged because the final ClawSweeper review of exact head 5ee8c1b reported no actionable or security findings with Diamond proof confidence, all 226 CI checks passed, and the compatibility gate returned SAFE with executable pre-upgrade bridge proof requiring no migration." Compatibility Checks Done: 226/226 CI checks green on the merged head; final ClawSweeper review reported no actionable or security findings with Diamond (5/6) proof confidence and checked the data-model compatibility item; compatibility review returned SAFE; an executable pre-upgrade bridge contract test drives all four mutation RPCs through the legacy bridge shape, and real-shell final-effect tests verify denials, exact landing, and post-authorization alias-swap immunity. |
…ions (openclaw#143501) * fix(sandbox): authorize canonical destinations before pinned fs mutations * fix(sandbox): separate policy namespace from pinned mutation targets * fix(sandbox): satisfy lint, deadcode, and test-type gates on pinned frames * test(sandbox): prove canonical authorization through RPC * test(sandbox): prove legacy bridge upgrade compatibility * fix(sandbox): reject canonical descendant copies * test(sandbox): cover legacy bridge mutation contracts
Summary
A sandboxed workload with workspace write access could modify files under a policy-protected path such as
.git— an ancestor symlink (placed once, or swapped mid-operation) redirected an approved write into a denied directory, and a planted.git/confighelper could execute with host privileges on the nextgitrun. This PR authorizes the canonical destination before every write-class mutation and pins the mutation to exactly that destination, so redirects fail closed. It replaces lexical-only authorization in the Codex exec-server filesystem handler and both shipped sandbox bridges.What was wrong
extensions/codex/src/app-server/sandbox-exec-server/filesystem.ts— the request-local policy was evaluated against the lexical request path only; the handler then delegated to the bridge, which resolved symlinks afterward. The policy never saw the real destination.src/agents/sandbox/fs-bridge.ts— the local bridge anchored mutations to the canonical (symlink-resolved) path with no link back to what the policy had authorized.src/agents/sandbox/remote-fs-bridge.ts— the remote bridge had the same authorization/mutation mismatch, and its pinned-target construction kept the filename in parent pins and resolved canonical paths in the physical namespace while policy grants use the logical one (breaking legitimate symlinked workspace roots).Net effect: an attacker-controlled ancestor symlink could silently redirect any approved workspace write into a read-only or denied path, including
.git/config.Why this design
resolvePinnedMutationTargetreturns two views —policyPath(the caller's logical policy namespace, evaluated together with the lexical path, so an alias cannot hide the real destination) andpinnedPath(the bridge-runtime canonical target, passed back so the mutation lands exactly there).mkdir, directory copy) authorize the directory itself — an existing alias may rename it and creation of an existing mount root stays an authorized no-op; file actions (write,create,remove,copy) authorize the canonical parent plus the requested basename, so a removal can never act on an unauthorized child.fs/writeFile,fs/createDirectory,fs/remove,fs/copy) in both shipped bridges.Request lifecycle
Every write-class request traverses the same gate ordering; each attack path terminates in a fail-closed state:
stateDiagram-v2 [*] --> Requested: fs/writeFile · copy · remove · mkdir Requested --> LexicalCheck LexicalCheck --> Denied: policy denies lexical path LexicalCheck --> CanonicalResolution: allowed CanonicalResolution --> CanonicalCheck: returns policyPath + pinnedPath CanonicalCheck --> Denied: policy denies canonical destination CanonicalCheck --> Pinned: both views authorized Pinned --> Landed: no-follow walk reaches pinned target Pinned --> Aborted: component swapped after authorization Denied --> [*] Aborted --> [*] Landed --> [*] Denied: denied before any effect (0 bytes moved, zero bridge mutations) Aborted: mutation aborted, not redirected (fail closed) Landed: landed on authorized target (final filesystem state verified).git) terminates at the canonical-policy gate — the gate that did not exist before this fix.Evidence
Observed final filesystem effects through the real WebSocket exec-server RPC with the shipped remote-shell bridge and real POSIX scripts (no mocks):
/workspace/alias/config(alias -> .git).git/config.git/configabsent, zero mutation-script invocations/workspace/real-note.txt/workspace/alias-real/config(alias -> real), alias swapped to a decoy after authorizationreal/config/workspace/nested/src-dir/workspace(existing mount root)/workspace/nested/src-dir/workspace/alias-dir(alias -> dir-target)/workspace/nested/src-dir/workspace/source-subdir-alias(alias -> source/subdir)mkdirpor enumeration: zero new mutation calls, no copied output/workspace/alias/gone.txt(alias -> real)real/gone.txtSink-level observations: every outcome above is asserted by reading back final filesystem state (or its absence) after the RPC completes — see the
sandbox-exec-server.fs-bridge-composition.test.tsand local-bridge E2E suites.SDK / caller upgrade contract
SandboxFsBridgeimplementers are the affected callers:resolvePinnedMutationTarget(and legacypinnedPath-less call sites) compile and run unchanged — a dedicated regression test constructs the exact pre-upgrade shape (satisfies SandboxFsBridge), drives all four mutation RPCs through the real handler, and asserts each method receives the unchanged legacy argument object.Boundary decisions requested from maintainers
resolvePinnedMutationTargetand everypinnedPathparameter are optional, so third-party bridges are not forced to adopt the guarantee in this release. Flag if a mandatory migration is preferred instead.Testing