Repository navigation
fix(sandbox): pin writable ancestors of nested protected skill mounts - #180840
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: needs maintainer review before merge. What this changesThis PR pins writable parent directories of protected skill mounts so sandbox processes cannot move them aside and replace protected paths. Example: A Docker sandbox running as UID 1000 has workspaceAccess="rw" and an existing /workspace/.agents/skills/demo/SKILL.md.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a demonstrated read-only skill protection bypass that remains on main and in the latest release; the previous writable-child finding is resolved, with no remaining introduced defect identified. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe sandbox mount planner turns workspace paths, protected skill roots, Gateway mount metadata, and custom binds into container mounts used by shell and browser runtimes and checked by workspace image readers. flowchart TD
A[Workspace and protected skill roots] --> B[Existing mount selection]
B --> C[Ancestor pins and source translation]
C --> D[Docker or Podman container]
D --> E[Kernel enforces protected paths]
C --> F[Workspace image backing validation]
Technical reviewBest possible solution: Use the existing mount planner to pin writable ancestors while preserving Gateway child permissions and exact workspace backing identity. Do we have a high-confidence way to reproduce the issue? The supplied before/after Docker trace demonstrates the parent-rename bypass, and current-main source retains the same vulnerable mount layout; this read-only review did not execute target code. Is this the best way to solve the issue? The fix enforces the existing read-only contract at the kernel mount boundary, reuses source translation and lifecycle owners, and includes the image-backing adjustment needed by the new mounts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 371306818eb6. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +141, Tests +118. Total +259 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 23, 2026, 2:01 AM ET / 06:01 UTC (Revision 4). |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merge recordSummary: Sandboxed shells could rename the parent directory of a nested read-only skill mount (e.g. Decision Reason for Merge: Merged because the user, who is the repository maintainer, directed the merge after Clawsweeper found no actionable findings across three review rounds (final rating Platinum 4/6, "Ready for maintainer review", "Before merge: None"). The bypass was reproduced in a container created by OpenClaw's own Compatibility Checks Done: Two compatibility passes were performed and recorded in the worklog: the first before shipping (no config, schema, default, or public SDK change; 3 files), re-run at the final loop state after the two review-driven fixes (both reduce compatibility risk: read-only Gateway submounts keep starting, images under pinned parents keep displaying, writable Gateway children beneath a read-only ancestor stay writable). Round-3 review confirmed no remaining introduced regressions. Locally on the final head: sandbox suite green (728 passed, 4 skipped), |
…openclaw#180840) * fix(sandbox): pin writable ancestors of nested protected skill mounts * fix(sandbox): keep Gateway access and image backing for pinned ancestors * fix(sandbox): leave read-only Gateway ancestors unpinned so writable children keep access * fix(sandbox): treat added ancestor pins as upgrade-safe protected mounts * fix(sandbox): track pinned ancestors by container target
Summary
With
workspaceAccess: "rw"(and private"none"workspaces), OpenClaw bind-mounts skill roots read-only at nested paths inside the writable workdir (<workdir>/.agents/skills,<workdir>/.openclaw/sandbox-skills/skills). Linux refuses to rename a mountpoint, but not its parent, so a sandboxed shell could move.agentsor.openclawaside and recreate the protected skill path as ordinary writable files. This PR binds each writable directory between the workdir and a nested protected mount onto itself, so those parents are mountpoints too and the rename fails withEBUSY. It complements #96028 and #126775, which handle different layers.What Problem This Solves
The docs promise that "local container mounts and sandbox file tools enforce these read-only roots." The sandbox file tools already refuse to rename a parent of a read-only mount (
requireWritable: "subtree"insrc/agents/sandbox/fs-bridge-mutation-helper.ts). Shellexecdoes not go through that check, so the sandboxed model could still replace a protected skill path:.agents/skills: the replacement lands in the host workspace. Host skill discovery picks it up, it can shadow a lower-precedence skill with the same name, and the next container recreate mounts the agent-written copy read-only..openclaw/sandbox-skills/skills:execand skill scripts inside the sandbox see the agent's copy instead of the managed one.After this change, a sandboxed process cannot move those parent directories, so the protected path keeps resolving to the real read-only mount. Ordinary edits to other files in those directories still work.
What was wrong
src/agents/sandbox/workspace-mounts.ts(resolveReadOnlyWorkspaceSkillMounts) plans protected mounts at nested container paths, but nothing pins the intermediate directories (.agents,.openclaw,.openclaw/sandbox-skills). They stay ordinary entries inside the writable workspace bind.src/agents/sandbox/mount-plan.ts(prepareSandboxMountPlan) emits only the workspace and protected-leaf binds, so in the created container those parents can be renamed by any sandboxed process.Net effect: a sandboxed
execcould detach the read-only mount and put agent-written instructions at the protected path.Why this design
.agentsor/workspace, so non-default workdirs are covered.mutationSymlinks: "reject",assertCurrent). Engines can't create them root-owned, and a symlinked parent fails closed.translateSandboxMountSourcespath, so Gateway-in-Docker deployments translate them like any other managed bind. Each one is ordered before the protected mount it pins.sandboxContainerShowsWorkspacePaths) to accept a covering self-bind only when its source is the workspace source at that same relative path, so images under.agents/still display and unrelated binds are still rejected.sandboxMountPlanMatchesContainermount-change handling.Why this does not conflict with related PRs
.agents/skillsstays nested and still needs this pinning. The two compose: if the materialized target becomes a direct child, no parent bind is produced for itEvidence of Fix
Both runs created the sandbox through OpenClaw's own
ensureSandboxContainer(rw workspace, shared scope,openclaw-sandbox:bookworm-slim, Docker 29.8.0), then ran commands withdocker execas the sandbox user (uid 1000). The host workspace held an inertSKILL.mdmarker withdescription: ORIGINAL.5730de35ae9)docker inspect)/workspacerw,/workspace/.agents/skillsro,/workspace/.openclaw/sandbox-skills/skillsro/workspace/.agents,/workspace/.openclaw,/workspace/.openclaw/sandbox-skillsmv /workspace/.agents …Device or resource busy, exit 1.agents/skills/demo/SKILL.mdREPLACEDORIGINALmv /workspace/.openclaw …Device or resource busy, exit 1mv /workspace/.openclaw/sandbox-skills …Read-only file systemon the protected child), exit 1Read-only file system, exit 1.agents/and.openclaw/Captured terminal output (scratch paths redacted)
Podman was not run locally. The reporter measured the same mount layout working on rootless Podman 6.1.3.
Testing
src/agents/sandbox/mount-plan.test.ts:pnpm vitest run src/agents/sandbox/: 56 files, 698 passed, 3 skipped.pnpm tsgo:corepasses; oxlint and oxfmt are clean on the changed files.