Skip to content

feat: add role-based Local computer permissions - #9472

Merged
w31r4 merged 42 commits into
masterfrom
codex/linux-bubblewrap-shell-sandbox
Sep 15, 2026
Merged

w31r4 merged 42 commits into
masterfrom
codex/linux-bubblewrap-shell-sandbox

Conversation

@Soulter

@Soulter Soulter commented Jul 30, 2026

Copy link
Copy Markdown
Member

Summary

  • replace the implicit Local behavior behind computer_use_require_admin with an explicit role-based permission matrix for members and administrators
  • configure three independent Local permissions: code execution, execution-environment network access, and access to files outside the workspace
  • enforce the resolved role policy consistently across Shell, Python, file tools, managed shell sessions, and the local-file message bridge
  • isolate any restricted execution on Linux with bubblewrap or on macOS with Seatbelt; unsupported platforms fail closed instead of falling back to unrestricted execution
  • keep computer_use_require_admin for remote Sandbox runtimes only, with its existing semantics and a Sandbox-only dashboard control
  • migrate legacy configurations automatically: the old switch determines member execution, while member network and filesystem access remain restricted

Default Local policy

Role Execute code Execution network Files outside workspace
Member No No No
Administrator Yes Yes Yes

The dashboard presents these permissions as a full-width Unix-style matrix directly below the Local runtime selector. Network access is disabled when execution is disabled, and elevated member access produces a visible warning.

The stored configuration remains explicit and forward-compatible:

computer_use_local_permissions:
  member:
    allow_execution: false
    allow_network: false
    filesystem_scope: workspace
  admin:
    allow_execution: true
    allow_network: true
    filesystem_scope: host

Runtime behavior

  • allow_execution=false denies new Shell and Python execution for that role.
  • allow_network=false isolates the process network namespace/profile.
  • filesystem_scope=workspace limits Shell, Python, read, write, edit, grep, and local file sending to approved workspace, Skill, and temporary roots.
  • any restricted execution uses the OS sandbox and retains CPU, process, file, descriptor, wall-time, and output limits.
  • a fully trusted policy (allow_network=true and filesystem_scope=host) preserves direct Local execution.
  • Windows currently supports execution only when disabled or fully trusted; restricted combinations fail closed and the dashboard explains this limitation explicitly. Use remote Sandbox when granular Windows isolation is required.

Linux requires bwrap and functional unprivileged user namespaces for restricted policies. macOS requires /usr/bin/sandbox-exec. Apple marks sandbox-exec as deprecated, so this implementation remains isolated behind the Local permission boundary and covered by integration tests.

Validation

  • uv run ruff format .
  • uv run ruff check .
  • focused permission, config, filesystem, message, shell, and Python tests: 183 passed, 1 skipped
  • main test suite excluding one host-plugin-sensitive cache module: 2073 passed, 1 skipped
  • the excluded cache module under a clean ASTRBOT_ROOT: 3 passed
  • pnpm exec vue-tsc --noEmit
  • pnpm exec vite build
  • macOS Seatbelt integration: host filesystem without network and workspace filesystem with network both enforced independently
  • Linux bubblewrap command coverage: workspace/host filesystem and isolated/shared network combinations are generated independently

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 30, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
astrbot-docs 2871b34 Commit Preview URL

Branch Preview URL
Sep 15 2026, 07:39 AM

@Soulter Soulter changed the title feat: sandbox local member execution on Linux feat: sandbox local member execution on Linux and macOS Jul 30, 2026
- Added `open_file_in_allowed_roots` function in `local_file_security.py` to securely open files within specified directories, preventing path traversal attacks.
- Updated file reading functions in `file_read_utils.py` to accept file descriptors, allowing for safer file operations.
- Enhanced `FileReadTool`, `FileWriteTool`, and `FileEditTool` to utilize the new secure file access method.
- Added tests to ensure restricted access works correctly, including scenarios with symlinked directories and ancestor swaps.
- Improved error handling for file operations to provide clearer feedback on permission issues.
Soulter added 2 commits August 2, 2026 16:17
…rap-shell-sandbox

# Conflicts:
#	astrbot/core/tools/computer_tools/shell.py
#	tests/unit/test_func_tool_manager.py
@Soulter Soulter changed the title feat: sandbox local member execution on Linux and macOS feat: add role-based Local computer permissions Aug 2, 2026
@RC-CHN
RC-CHN requested a review from w31r4 September 3, 2026 07:30
@RC-CHN
RC-CHN marked this pull request as ready for review September 8, 2026 02:14

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @RC-CHN, your pull request is larger than the review limit of 150,000 diff characters

Sandboxed processes can write to shared temp roots, so a named session
log there could be replaced with a symlink to a host file that host-side
reads and appends would follow. Keep managed shell output on an anonymous
temporary file handle instead of a named path.

Also stop _resolve_path_from_sandbox from consulting a booter under the
local runtime: workspace and local-file checks already enforce caller
permissions, and the fallback branch probed the host shell without them.
Reject such paths with FileNotFoundError instead.
@w31r4

w31r4 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@RC-CHN 冲突解一下

@w31r4 w31r4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

勉强采用的方案, 隔离不充分不彻底, 凑合的 Beta 版本

@w31r4
w31r4 merged commit 06261c5 into master Sep 15, 2026
24 checks passed
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.

4 participants