sbxis an easy-to-use command-line tool for running commands with macOS sandbox-exec policies using flag-based interface.- This command is heavily inspired by littledivy's sh-deno.
- Easy allow/deny configuration for common operations (file, network, process, etc.)
- Supports both of relative and absolute path filtering.
- This command is using deprecated feature (sandbox-exec).
- This command is experimental and unstable.
- This command implicitly applies
Common system sandbox ruleswhich is defined in "system.sb". - This command also allows access to dylibs because it's required for process exec.
- When you specify
-networkflag, this command allows access to unix-socket.
go install github.com/syumai/sbx/cmd/sbx@latest
or download binary from releases page.
sbx [flags] <command> [command-args...]
sbx [flags] -- <command> [command-flags] [command-args...]
- By default,
sbxdenies all operations.- To allow all operations for investigation purposes, use the
--allow-allflag.
- To allow all operations for investigation purposes, use the
- You can allow operations by specifying the corresponding flags.
- You can deny operations by specifying the corresponding flags with
deny-prefix. -allflags are boolean flags that allow / deny all operations for the corresponding operation type.- Another flags requires a path arguments as comma-separated values.
-networkflags supports only settings below.- only
ipprotocol. - only
localhostor*for host.
- only
--allow-allAllow all operations (without this flag, deny all operations by default)
--allow-fileAllow file operations--deny-fileDeny file operations--allow-file-allAllow all file operations--deny-file-allDeny all file operations
--allow-file-readAllow file read operations--deny-file-readDeny file read operations--allow-file-read-allAllow all file read operations--deny-file-read-allDeny all file read operations
--allow-file-writeAllow file write operations--deny-file-writeDeny file write operations--allow-file-write-allAllow all file write operations--deny-file-write-allDeny all file write operations
--allow-network-allAllow all network operations--deny-network-allDeny all network operations--allow-network-inboundAllow inbound network operations--deny-network-inboundDeny inbound network operations--allow-network-outboundAllow outbound network operations--deny-network-outboundDeny outbound network operations
--allow-process-execAllow process execution--deny-process-execDeny process execution--allow-process-exec-allAllow all process execution--deny-process-exec-allDeny all process execution
- Allow read operation for current directory.
sbx --allow-file-read . ls .
# same as above
sbx --allow-file-read='.' ls .
# with command flags
sbx --allow-file-read='.' -- ls -l .- Allow network operation for
localhost:8080.
sbx --allow-network='localhost:8080' curl http://localhost:8080- Allow network operation for remote host.
- Allow read access to the
/opt/localdirectory to retrieve CA certificates. (This example uses homebrew-installedcurl.)
- Allow read access to the
sbx --allow-network='*:443' --allow-file-read='/opt/local' curl https://syum.ai/asciiMIT