Skip to content

fix(sandbox): create skills dirs before first container launch - #94433

Closed
lsr911 wants to merge 2 commits into
openclaw:mainfrom
lsr911:fix/issue-94425-Security-Bug-Sandbox-skills
Closed

lsr911 wants to merge 2 commits into
openclaw:mainfrom
lsr911:fix/issue-94425-Security-Bug-Sandbox-skills

Conversation

@lsr911

@lsr911 lsr911 commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Create skills and .agents/skills directories eagerly during ensureAgentWorkspace to prevent a first-write vulnerability window in sandbox containers.

Problem

When a new agent workspace has no skills or .agents/skills directories, read-only mount instructions are silently skipped by resolveReadOnlyWorkspaceSkillMounts. This creates a window where the agent can freely run mkdir skills and write executable scripts before the protective ro mount is applied on restart.

Root Cause

ensureAgentWorkspace does not create the skills directories upfront. The Docker ro mount is only applied if the paths already exist on the host, so the first container launch runs without the sandbox protection on these paths.

Changes

  • src/agents/workspace.ts — +5 lines: create both skills and .agents/skills directories eagerly during ensureAgentWorkspace, guaranteeing they exist before any sandbox container spawns. The Docker ro mount lock now always applies from the first launch.

Testing

CI verification (pnpm not available locally).

Related

Closes #94425

When a new agent workspace has no skills or .agents/skills
directories, the read-only mount instructions are silently
skipped. This creates a first-write vulnerability window where
the agent can freely create executable scripts before the
protective ro mount is applied on restart.

Create both directories eagerly during workspace initialization
so the Docker ro mount lock always applies from the first
container launch.

Fixes openclaw#94425

Co-Authored-By: Claude <[email protected]>
@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 18, 2026
@clawsweeper

clawsweeper Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

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

Summary
This PR adds eager creation of skills and .agents/skills inside ensureAgentWorkspace so sandbox read-only skill mounts have host sources before first container launch.

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

Reproducibility: yes. from source inspection. The rw sandbox setup path only creates the workspace root before mount resolution, and the added .agents/skills directory is visible to the existing skip-bootstrap content-evidence scanner.

Review metrics: 1 noteworthy metric.

  • Generated workspace directories: 2 added. The new directories are created before workspace evidence checks and before sandbox mount assumptions, so their ordering matters for merge safety.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #94425
Summary: This PR is a candidate fix for the open sandbox skill-directory issue, and a sibling open PR targets the same root cause; neither has merged as a safe canonical fix.

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 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:

  • [P1] Move the fix to the workspaceAccess: "rw" sandbox setup path before mount resolution.
  • Preserve skip-bootstrap wiped-workspace detection while adding the generated directories.
  • [P1] Add redacted real behavior proof for the actual sandbox mount path after updating the PR body.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body says pnpm was unavailable and relies on CI, so there is no after-fix real behavior proof for the sandbox or Docker mount path. 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 this as-is can leave the linked sandbox security issue only partially fixed because the workspaceAccess: "rw" runtime setup path can still reach mount resolution without the agent skill source directories.
  • [P1] Creating .agents/skills before workspace content checks can make wiped skip-bootstrap workspaces look non-empty and bypass the existing WorkspaceVanishedError guard.
  • [P1] The contributor did not supply after-fix real behavior proof for the actual sandbox or Docker mount path.

Maintainer options:

  1. Fix runtime path and evidence guard (recommended)
    Move the directory creation into the workspaceAccess: "rw" sandbox setup before mount resolution, keep generated .agents/skills from satisfying wipe-detection evidence, and add regression plus real behavior proof.
  2. Pause in favor of the canonical issue
    If maintainers do not want to repair this branch, leave the canonical issue open and close or replace this PR only after a proof-positive fix exists.

Next step before merge

  • [P1] Manual review is needed because this external security-boundary PR has blocking findings and missing real behavior proof.

Security
Needs attention: The patch is security-sensitive and does not reliably close the reported sandbox skill-directory bypass.

Review findings

  • [P1] Create skill dirs in the rw sandbox path — src/agents/workspace.ts:879-880
  • [P1] Preserve skip-bootstrap wipe detection — src/agents/workspace.ts:880
Review details

Best possible solution:

Create the host skills and .agents/skills directories in the writable sandbox setup path before mount resolution, preserve skip-bootstrap wipe detection, and prove the real sandbox path.

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

Yes from source inspection. The rw sandbox setup path only creates the workspace root before mount resolution, and the added .agents/skills directory is visible to the existing skip-bootstrap content-evidence scanner.

Is this the best way to solve the issue?

No. Adding the directories in ensureAgentWorkspace is useful for some setup paths but is not the narrowest safe fix for the container launch path and it regresses workspace wipe detection.

Full review comments:

  • [P1] Create skill dirs in the rw sandbox path — src/agents/workspace.ts:879-880
    These mkdirs only run when a caller invokes ensureAgentWorkspace. The workspaceAccess: "rw" sandbox setup path still only creates workspaceDir before Docker resolves agentWorkspaceDir/skills and .agents/skills, so configured or manual workspaces that lack those dirs can still get no read-only overlays on first launch. Move the guard into the rw sandbox layout before mount resolution and cover that path.
    Confidence: 0.92
  • [P1] Preserve skip-bootstrap wipe detection — src/agents/workspace.ts:880
    Creating .agents/skills before hasSkipBootstrapWorkspaceContentEvidence() means the scanner sees .agents as user content. Existing skip-bootstrap wipe tests that expect WorkspaceVanishedError would be bypassed after this patch; create these dirs after the vanished/content check or ignore empty generated .agents/skills there.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P1: The PR targets a sandbox security-boundary bug that can leave writable skill paths inside new rw sandboxes.
  • add merge-risk: 🚨 compatibility: The patch changes workspace bootstrap side effects and can bypass existing skip-bootstrap wiped-workspace detection.
  • add merge-risk: 🚨 security-boundary: The patch can make the linked sandbox skill-mount bypass appear fixed while the runtime rw path still omits read-only overlays.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body says pnpm was unavailable and relies on CI, so there is no after-fix real behavior proof for the sandbox or Docker mount path. 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.

Label justifications:

  • P1: The PR targets a sandbox security-boundary bug that can leave writable skill paths inside new rw sandboxes.
  • merge-risk: 🚨 compatibility: The patch changes workspace bootstrap side effects and can bypass existing skip-bootstrap wiped-workspace detection.
  • merge-risk: 🚨 security-boundary: The patch can make the linked sandbox skill-mount bypass appear fixed while the runtime rw path still omits read-only overlays.
  • 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 real behavior proof before merge: The PR body says pnpm was unavailable and relies on CI, so there is no after-fix real behavior proof for the sandbox or Docker mount path. 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 +5. Total +5 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 5 0 +5
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 5 0 +5

Security concerns:

  • [high] Patch misses the runtime sandbox mount path — src/agents/workspace.ts:879
    The added mkdirs are in ensureAgentWorkspace, but current rw sandbox launch can resolve Docker read-only skill mounts after only creating the workspace root, leaving missing agent skill sources unmounted.
    Confidence: 0.92

What I checked:

  • PR patch location: The branch inserts both directory creations immediately after the workspace root mkdir in ensureAgentWorkspace, before the skip-bootstrap content-evidence check runs. (src/agents/workspace.ts:879, 1274d6e5ac27)
  • Writable sandbox setup path: Current main's workspaceAccess: "rw" path only creates workspaceDir directly and then syncs skills; it does not call ensureAgentWorkspace before mount resolution. (src/agents/sandbox/context.ts:119, c6aa8e74236f)
  • Mount filtering contract: Read-only workspace skill mounts are emitted only for existing agentWorkspaceDir/skills and agentWorkspaceDir/.agents/skills directories, so missing source directories are still omitted. (src/agents/sandbox/workspace-mounts.ts:70, c6aa8e74236f)
  • Docker caller ordering: Docker resolves the read-only skill mounts before creating the container, so the host directories must exist before ensureSandboxContainer computes readOnlyWorkspaceSkillMounts. (src/agents/sandbox/docker.ts:635, c6aa8e74236f)
  • Skip-bootstrap content evidence: The content-evidence scanner ignores empty skills but not an empty generated .agents/skills parent, so creating .agents/skills before this check can make a wiped workspace appear user-populated. (src/agents/workspace.ts:305, c6aa8e74236f)
  • Existing regression coverage: Current tests expect recently attested skip-bootstrap workspaces that are wiped to be rejected; this patch's early .agents/skills creation would satisfy the content-evidence check instead. (src/agents/workspace.test.ts:324, c6aa8e74236f)

Likely related people:

  • brokemac79: Authored the merged writable-sandbox materialized-skills implementation that shaped the current rw sandbox skills path. (role: feature owner; confidence: high; commits: 3b6bcbfb5045, 741e301e6a59; files: src/agents/sandbox/context.ts, src/skills/loading/workspace.ts, src/agents/sandbox/workspace-mounts.ts)
  • steipete: Merged the materialized-skills PR and authored follow-up hardening around sandbox skill mounts and remote skill refresh paths. (role: merger and adjacent area contributor; confidence: high; commits: 3b6bcbfb5045, a0f6ce03ce88; files: src/agents/sandbox/workspace-mounts.ts, src/agents/sandbox/docker.ts, src/skills/loading/workspace.ts)
  • jason-allen-oneal: Authored the merged PR that added the original sandbox workspace skill read-only mount behavior and related tests. (role: introduced read-only skill mount behavior; confidence: medium; commits: 5186a1b3aed5, 5df37b4f6c1f; files: src/agents/sandbox/workspace-mounts.ts, src/agents/sandbox/workspace-mounts.test.ts, src/agents/sandbox/docker.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. labels Jun 18, 2026
The sandbox skills dir creation code adds .agents/skills/ before the
workspace-vanished check.  The freshly-created .agents/ parent directory
was then detected as user content evidence by
hasSkipBootstrapWorkspaceContentEvidence, preventing the
WorkspaceVanishedError from being thrown when a workspace was wiped.

Add .agents to the metadata skip list — it is a standard config
directory (agent-level skills, etc.), not user-created content.

Fixes the agents-core-runtime CI failure on PR openclaw#94433.

Co-Authored-By: Claude <[email protected]>
@lsr911

lsr911 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Closing stale PR: no human engagement detected. Only bot comments found. Will reopen if a maintainer expresses interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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