Skip to content

fix(sandbox): create missing skill mount directories to enforce read-only protection - #94820

Closed
ajwan8998 wants to merge 1 commit into
openclaw:mainfrom
ajwan8998:fix/issue-94425-sandbox-readonly
Closed

ajwan8998 wants to merge 1 commit into
openclaw:mainfrom
ajwan8998:fix/issue-94425-sandbox-readonly

Conversation

@ajwan8998

@ajwan8998 ajwan8998 commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #94425

What Problem This Solves

Sandbox skill directories were not mounted read-only on first agent creation. isExistingWorkspaceSkillMountSource returned false when the host directory didn't exist, causing the read-only bind mount to be silently skipped.

Why This Change Was Made

In the catch block (when lstatSync throws), create the missing directory so the read-only mount is always applied.

Evidence

$ npx tsx -e ...

=== Before fix (dir does not exist) ===
  isExistingWorkspaceSkillMountSource → false
  Mount result: SILENTLY SKIPPED (read-only protection lost)

=== After fix (dir does not exist) ===
  isExistingWorkspaceSkillMountSource → true
  Directory created: true
  Docker mount args: -v /tmp/../sandbox-skills:ro,z
  Mount result: APPLIED with :ro,z (read-only)

The Docker bind mount now includes :ro,z (read-only) even on first agent creation. When the directory already exists, behavior is identical (no regression).

@ajwan8998
ajwan8998 requested a review from a team as a code owner June 19, 2026 06:18
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 24, 2026, 3:00 AM ET / 07:00 UTC.

Summary
The PR changes sandbox skill mount-source filtering so missing host directories are created inside isExistingWorkspaceSkillMountSource and then treated as read-only bind mount sources.

PR surface: Source +10. Total +10 across 1 file.

Reproducibility: yes. at source level: current main returns false for missing skill roots, which filters out read-only overlays before Docker and browser container creation. I did not run a live first-launch Docker repro in this read-only review.

Review metrics: 1 noteworthy metric.

  • Mount-source side effects: 1 predicate changed. The changed helper feeds sandbox mount args, config hashes, browser containers, filesystem bridge, and remote-bridge decisions, so the side effect matters before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #94425
Summary: This PR is an open candidate fix for the canonical first-launch missing skill mount source sandbox issue; the newer related PR addresses the same root cause but is not yet a terminal supersession.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Re-stat after mkdir and run canonical-root validation before accepting a mount source.
  • [P1] Add regression coverage for a missing child under a symlinked parent.
  • [P1] Add redacted first-launch Docker or sandbox terminal proof showing writes to protected skill paths fail.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body includes helper-level terminal output, but it still needs redacted first-launch Docker or sandbox terminal proof showing writes to protected skill paths fail; after updating the PR body, re-review should run or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Merging as-is can create a missing skill source through a symlinked parent and accept it as a protected read-only mount without canonical-root validation.
  • [P1] Changing this predicate from filter-only to mkdir-capable adds filesystem side effects to Docker, browser, fs-path, agent-tool, and remote-bridge mount decisions.
  • [P1] The PR body shows helper-level terminal output, but not a first-launch Docker or sandbox run proving writes to protected skill paths fail.

Maintainer options:

  1. Repair this branch before merge (recommended)
    Re-stat after mkdir, run the existing canonical-root check before accepting the mount, add missing-child-under-symlink-parent coverage, and require first-launch sandbox proof.
  2. Move creation into sandbox setup
    Materialize protected roots during rw sandbox workspace setup so the mount-source predicate remains validation-only for shared callers.
  3. Prefer the newer candidate only after review
    If fix(sandbox): materialize protected skill mount roots #96028 clears human review and real behavior proof, maintainers can treat this PR as superseded then.

Next step before merge

  • [P1] Human review and contributor proof are needed because the remaining blockers include a security-boundary defect, missing real sandbox proof, and a newer related candidate that maintainers may prefer after review.

Security
Needs attention: The diff changes sandbox mount-source selection and can weaken canonical-root protection when missing paths under symlinked parents are accepted without revalidation.

Review findings

  • [P1] Preserve root validation after mkdir — src/agents/sandbox/workspace-mounts.ts:58
Review details

Best possible solution:

Materialize missing protected skill roots before mount resolution, or revalidate after mkdir, while preserving canonical-root and symlink-parent coverage plus redacted first-launch sandbox proof.

Do we have a high-confidence way to reproduce the issue?

Yes at source level: current main returns false for missing skill roots, which filters out read-only overlays before Docker and browser container creation. I did not run a live first-launch Docker repro in this read-only review.

Is this the best way to solve the issue?

No. Creating missing directories is a plausible fix direction, but returning true before canonical-root validation is not the safest implementation; setup-time materialization or post-mkdir revalidation is the narrower maintainable shape.

Full review comments:

  • [P1] Preserve root validation after mkdir — src/agents/sandbox/workspace-mounts.ts:58
    When lstatSync fails for a missing child below a symlinked parent, this branch creates the directory and returns true before the canonical source/root check below. That can accept a skill mount whose real host path is outside the workspace; re-stat the created path and run the existing containment check before returning.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against a96418c65f8f.

Label changes

Label justifications:

  • P1: The PR targets a sandbox security-boundary bug that can leave executable skill directories writable on first launch.
  • merge-risk: 🚨 compatibility: Creating host skill directories during mount resolution changes first-run filesystem side effects and sandbox config hash inputs for existing sandbox flows.
  • merge-risk: 🚨 security-boundary: The patch decides which host paths become protected sandbox skill mounts and bypasses the existing canonical-root guard on the missing-directory path.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body includes helper-level terminal output, but it still needs redacted first-launch Docker or sandbox terminal proof showing writes to protected skill paths fail; after updating the PR body, re-review should run or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +10. Total +10 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 13 3 +10
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 13 3 +10

Security concerns:

  • [high] Mount source accepted before canonical-root validation — src/agents/sandbox/workspace-mounts.ts:58
    Creating and immediately accepting a missing path skips the existing post-lstat canonical root comparison, which is the guard that prevents symlinked parent paths from becoming sandbox mount sources.
    Confidence: 0.9

What I checked:

  • PR bypasses validation after mkdir: At the PR head, the missing-path branch creates params.hostPath and immediately returns true, so the canonical-root containment check below is skipped for newly created sources. (src/agents/sandbox/workspace-mounts.ts:58, 0844054753b3)
  • Current main validates existing mount sources: Current main only accepts existing directories after resolving both root and source through existing ancestors and checking containment with isPathInside. (src/agents/sandbox/workspace-mounts.ts:57, a96418c65f8f)
  • Existing tests protect symlink-parent rejection: Adjacent coverage rejects skill roots through a symlinked parent, which is the invariant the PR's early return can bypass for a missing child under that symlink. (src/agents/sandbox/workspace-mounts.test.ts:128, a96418c65f8f)
  • Runtime callers consume the filtered mount list: Docker and browser sandbox creation compute read-only skill mounts before config hashing and container creation, so changing the predicate affects actual sandbox mounts and recreate identity. (src/agents/sandbox/docker.ts:604, a96418c65f8f)
  • Sibling surfaces share the predicate: The same helper is also used by the remote filesystem bridge, filesystem path projection, and agent tool read-only guard paths, so the new mkdir side effect is not isolated to Docker. (src/agents/sandbox/remote-fs-bridge.ts:706, a96418c65f8f)
  • Current release still has the original missing-root behavior: The latest release tag still returns false when the mount source is missing, so the underlying issue is not shipped as fixed and this PR is not obsolete on release provenance. (src/agents/sandbox/workspace-mounts.ts:49, aa69b12d0086)

Likely related people:

  • jason-allen-oneal: Authored the merged read-only workspace skill mount work and adjacent tests that define the protected skill overlay invariant. (role: introduced behavior; confidence: high; commits: 1b7bf4a56f9c; files: src/agents/sandbox/workspace-mounts.ts, src/agents/sandbox/workspace-mounts.test.ts, src/agents/sandbox/docker.ts)
  • brokemac79: Authored rw sandbox skills materialization work that threads the materialized skills workspace through this mount-resolution surface. (role: feature owner; confidence: high; commits: 3b6bcbfb5045, b71d8e1c32e3; files: src/agents/sandbox/context.ts, src/agents/sandbox/workspace-mounts.ts, src/agents/sandbox/remote-fs-bridge.ts)
  • steipete: Authored sandbox skill mount and remote skill guard hardening in the same mount and bridge paths. (role: adjacent hardening contributor; confidence: high; commits: a3526789a44f, a0f6ce03ce88, a8f68877a5c0; files: src/agents/sandbox/workspace-mounts.ts, src/agents/sandbox/remote-fs-bridge.ts, src/agents/sandbox/docker.ts)
  • vincentkoc: Recent current-main history includes sandbox helper export/refactor work carrying this helper and its callers forward. (role: recent area contributor; confidence: medium; commits: be4c54117683; files: src/agents/sandbox/workspace-mounts.ts, src/agents/sandbox/docker.ts, src/agents/sandbox/context.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 19, 2026
@ajwan8998

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@ajwan8998

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@ajwan8998

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

1 similar comment
@ajwan8998

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@ajwan8998

Copy link
Copy Markdown
Contributor Author

This PR is superseded by #96028 which correctly moves directory creation into sandbox workspace setup (ensureReadOnlyWorkspaceSkillMountSources) instead of inside the mount-source predicate. Closing.

@ajwan8998

Copy link
Copy Markdown
Contributor Author

Superseded by #96028

@ajwan8998 ajwan8998 closed this Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security/Bug] Sandbox 'skills' directory lacks initial read-only protection if host directory is missing upon agent creation

1 participant