Rugo supports opt-in process sandboxing using Linux Landlock. Add a sandbox directive to restrict what your script can access — filesystem paths and network ports.
# Deny everything (maximum restriction)
sandbox
# Allow specific paths
sandbox ro: ["/etc"], rw: ["/tmp"], rox: ["/usr/bin"]
# Allow network
sandbox connect: [80, 443], bind: 8080
# Paths support $VAR expansion at runtime
sandbox ro: ["$HOME/.config"], rw: ["$TMPDIR"]| Keyword | Access | Example |
|---|---|---|
ro |
Read-only | Config files |
rw |
Read + write | Temp/output dirs |
rox |
Read + execute | Binary dirs |
rwx |
Read + write + execute | Plugin dirs |
connect |
TCP connect | HTTP clients |
bind |
TCP bind | Servers |
env |
Env var allowlist | Restrict env access |
Apply sandbox restrictions without modifying the script:
rugo run --sandbox --ro /etc --rox /usr --connect 443 --env PATH script.rugoCLI flags override any sandbox directive in the script.
- Linux only: On other platforms, the directive is a no-op with a warning.
- No auto-allows: You must explicitly allow every path. Shell commands typically need
rox: ["/usr", "/lib"]andrw: ["/dev/null"]. - Symlinks: Landlock restricts the target path. Check with
readlink -f. - stat() is not restricted:
os.file_exists()always works regardless of sandbox.
Restrict which env vars are visible (opt-in, works on all platforms):
sandbox env: ["PATH", "HOME"]
import "os"
puts(os.getenv("HOME")) # works
puts(os.getenv("SECRET")) # empty stringsandbox ro: ["/etc"], rox: ["/usr", "/lib"], rw: ["/dev/null"]
result = `cat /etc/resolv.conf`
puts(result)For the full reference, see docs/sandbox.md.