Skip to content

fix(sandbox): ensure skill mount dirs exist before read-only mount resolution - #94460

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

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

Conversation

@qingminglong

Copy link
Copy Markdown
Contributor

Summary

  • Ensures sandbox skill directories (skills, .agents/skills, .openclaw/sandbox-skills) are created before isExistingWorkspaceSkillMountSource checks them
  • Fixes a vulnerability where these directories didn't exist on first agent launch, causing the read-only mount to be skipped and making skill sources writable inside the sandbox

Fixes #94425

Real behavior proof (required for external PRs)

Behavior addressed: On first sandbox agent launch, skill source directories don't exist yet because ensureAgentWorkspace doesn't create them. isExistingWorkspaceSkillMountSource returns false for non-existent directories, so resolveReadOnlyWorkspaceSkillMounts returns an empty list - the read-only overlay mount is skipped entirely.

Real setup tested:

  • Runtime: node (unit test suite)

Exact steps or command run after fix:

pnpm vitest run src/agents/sandbox/workspace-mounts.test.ts src/agents/sandbox/docker.config-hash-recreate.test.ts src/agents/sandbox/config-hash.test.ts src/agents/sandbox/browser.create.test.ts src/agents/agent-tools.sandbox-mounted-paths.workspace-only.test.ts

After-fix evidence:

PASS (26) FAIL (0) - workspace-mounts.test.ts
PASS (16) FAIL (0) - docker.config-hash-recreate.test.ts
PASS (11) FAIL (0) - config-hash.test.ts
PASS (36) FAIL (0) - browser.create.test.ts
PASS (12) FAIL (0) - agent-tools.sandbox-mounted-paths.workspace-only.test.ts

Observed result after the fix: All 101 tests pass across 5 test files. The mkdirSync loop creates all 3 skill directories before isExistingWorkspaceSkillMountSource filtering, so read-only mounts are consistently applied even on first launch.

What was not tested: Full Docker sandbox end-to-end (requires Docker daemon). The fix is validated through unit tests.

Proof limitations or environment constraints: Unit tests verify the mount arg output matches expectations; a Docker integration test would additionally confirm the container layers compose correctly.

Tests and validation

All 5 test files pass (101 tests total):

  • workspace-mounts.test.ts - 26 tests covering all 3 skill mount sources
  • docker.config-hash-recreate.test.ts - 16 tests covering config-hash consistency
  • config-hash.test.ts - 11 tests for mount format version stability
  • browser.create.test.ts - 36 tests including browser skill overlay ordering
  • agent-tools.sandbox-mounted-paths.workspace-only.test.ts - 12 workspace-only guard tests

Risk checklist

Did user-visible behavior change? (No)

  • Internal sandbox security hardening only

Did config, environment, or migration behavior change? (No)

Did security, auth, secrets, network, or tool execution behavior change? (Yes)

  • Sandbox skill directories are now always read-only, even on first agent launch
  • Prevents sandboxed agents from modifying skill instructions

What is the highest-risk area?

  • Existing sandbox containers created before this fix had writable skill dirs. After upgrade, newly created containers will have read-only skills

How is that risk mitigated?

  • Read-only skill mounts are an established security pattern in the codebase; this fix ensures they are applied consistently. No running sandbox state changes.

Current review state

What is the next action?

  • Maintainer review

What is still waiting on author, maintainer, CI, or external proof?

  • Docker integration test (requires Docker daemon, not available in this environment)

Which bot or reviewer comments were addressed?

  • N/A

…solution

Sandbox skill directories (skills, .agents/skills, .openclaw/sandbox-skills)
are now created via fs.mkdirSync before isExistingWorkspaceSkillMountSource
checks them. This fixes the vulnerability where these directories didn't
exist on first agent launch, causing the read-only mount to be skipped and
making skill sources writable inside the sandbox.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@qingminglong
qingminglong requested a review from a team as a code owner June 18, 2026 06:23
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 18, 2026
@qingminglong

Copy link
Copy Markdown
Contributor Author

Have a nice day, please help me merge

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

Labels

agents Agent runtime and tooling proof: supplied External PR includes structured after-fix real behavior proof. size: S

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

2 participants