Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Policies

TOML policy files configure the sandbox for sandtrace run. They define filesystem access, network permissions, syscall filters, and resource limits.

Policy format

[filesystem]
allow_read = ["/usr", "/lib", "/lib64", "/etc/ld.so.cache", "/dev/null", "/proc/self"]
allow_write = ["./output"]
allow_exec = []
deny = ["/home/*/.ssh", "/etc/shadow", "**/.env"]

[network]
allow = false

[syscalls]
deny = ["mount", "ptrace", "reboot"]
log_only = ["mprotect", "mmap"]

[limits]
timeout = 30

Sections

[filesystem]

FieldDescription
allow_readPaths the sandboxed process can read
allow_writePaths the sandboxed process can write to
allow_execPaths from which the sandboxed process can execute binaries
denyPaths that are always blocked, even if matched by an allow rule

Path patterns support globs (*, **). Deny rules take precedence over allow rules.

[network]

FieldDescription
allowWhether to allow network access (true/false)

When false, the sandbox creates an isolated network namespace with no external connectivity.

[syscalls]

FieldDescription
denySyscalls to block (returns EPERM)
log_onlySyscalls to log but allow

Note: The always-blocked syscalls are blocked regardless of policy configuration.

[limits]

FieldDescription
timeoutKill the process after N seconds

Example policies

Example policies are included in the examples/ directory:

FileDescription
strict.tomlMinimal filesystem access, no network, blocked dangerous syscalls
permissive.tomlBroad read access, trace-focused
npm_audit.tomlTuned for npm install sandboxing
pnpm_audit.tomlTuned for pnpm install sandboxing
composer_audit.tomlTuned for composer install sandboxing

Usage

sandtrace run --policy examples/strict.toml ./untrusted-binary
sandtrace run --policy examples/npm_audit.toml npm install

Policy flags can be combined with CLI flags. CLI flags (--allow-path, --allow-net, etc.) are merged with policy file settings, with CLI flags taking precedence.

Writing your own policies

Start from one of the example policies and customize:

  1. Start strict — begin with strict.toml and add only what the binary needs.
  2. Use trace-only first — run with --trace-only to see what the binary accesses, then write a policy based on the trace.
  3. Deny sensitive paths — always deny ~/.ssh, ~/.aws, ~/.gnupg, and .env files.
  4. Log before blocking — use log_only for syscalls you're unsure about before adding them to deny.