Skip to content

fix(security): restrict inbound media staging to media directory#4893

Closed
evanotero wants to merge 4 commits intoopenclaw:mainfrom
evanotero:fix/sandbox-bypass
Closed

fix(security): restrict inbound media staging to media directory#4893
evanotero wants to merge 4 commits intoopenclaw:mainfrom
evanotero:fix/sandbox-bypass

Conversation

@evanotero
Copy link
Copy Markdown
Contributor

Summary

This PR fixes a critical sandbox bypass vulnerability where host files could be exfiltrated into a restricted agent workspace.

Description

The 'stageSandboxMedia' function previously copied any absolute path provided in the 'MediaPaths' context into the agent's sandbox workspace without validation. This allowed a malicious plugin or hook to pull sensitive host files (e.g., '/etc/shadow') into the sandbox where they could be read by a restricted agent.

This fix:

  1. Integrates 'assertSandboxPath' to verify that all source paths are located within the designated OpenClaw media storage directory before performing a copy operation.
  2. Adds a regression test suite that verifies unauthorized host files are blocked from being staged.

Testing

  • Created a new security test 'src/auto-reply/reply.triggers.trigger-handling.stages-inbound-media-into-sandbox-workspace.security.test.ts' that confirms the bypass is blocked.
  • Verified that existing media staging tests still pass.
  • Verified that the changes do not introduce any lint errors.

@tyler6204 tyler6204 self-assigned this Jan 31, 2026
@tyler6204
Copy link
Copy Markdown
Member

Closing this in favor of #4930 which is a superset of this PR (includes the same assertSandboxPath fix plus agent hint updates and doc improvements). Credit to @evanotero for the original fix — already co-authored in #4930. Thanks!

@tyler6204 tyler6204 closed this Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants