Skip to content

fix: align macOS seatbelt sandbox with Codex whitelist policy#58

Merged
yishuiliunian merged 1 commit intomainfrom
fix/macos-seatbelt-sandbox-permissions
Apr 1, 2026
Merged

fix: align macOS seatbelt sandbox with Codex whitelist policy#58
yishuiliunian merged 1 commit intomainfrom
fix/macos-seatbelt-sandbox-permissions

Conversation

@yishuiliunian
Copy link
Copy Markdown
Contributor

Summary

  • Bazel/JVM crashed inside the macOS sandbox-exec sandbox due to missing iokit-open, signal, pseudo-tty, and ipc-posix-sem permissions
  • Rewrote the seatbelt profile to align with Codex's whitelist approach: scoped signal/process-info to same-sandbox, whitelisted specific sysctl, mach-lookup services, and iokit device classes
  • Extracted static policy rules into seatbelt_base.sbpl loaded via include_str!, keeping dynamic sections (writable paths, network) in Rust

Changes

  • crates/loopal-sandbox/src/platform/seatbelt_base.sbplnew: static Seatbelt base policy (~110 lines)
  • crates/loopal-sandbox/src/platform/macos.rs — rewritten to compose from .sbpl + dynamic sections
  • crates/loopal-sandbox/BUILD.bazel — added compile_data for .sbpl files
  • crates/loopal-sandbox/tests/suite/platform_macos_test.rs — updated tests for new profile structure

Test plan

  • bazel test //crates/loopal-sandbox:loopal-sandbox_test — PASSED
  • bazel build //crates/loopal-sandbox --config=clippy — zero warnings
  • Integration: sandbox-exec with new profile + bazel info — instant success
  • Verified: node, python, git, cargo, curl, pty, semaphore all work under new profile
  • CI passes

The previous seatbelt profile used broad (allow sysctl-read),
(allow mach-lookup), etc. which was both too permissive and
simultaneously missing critical permissions (iokit-open, signal,
pseudo-tty, ipc-posix-sem) that caused JVM/Bazel to crash inside
the sandbox.

Rewrite to a Codex-inspired whitelist approach:
- Extract static rules into seatbelt_base.sbpl (include_str!)
- Whitelist sysctl-read by prefix (hw.*, kern.os*, machdep.cpu.*)
- Whitelist mach-lookup for ~20 specific system services
- Scope signal and process-info to (target same-sandbox)
- Limit iokit-open to RootDomainUserClient only
- Add PTY device rules, ipc-posix-sem/shm, file-map-executable
- Keep dynamic composition for file-read/write paths and network
@yishuiliunian yishuiliunian merged commit 4ec7b0b into main Apr 1, 2026
3 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.

1 participant