Commit Graph

19 Commits

Author SHA1 Message Date
mrtoth 8f30d28965 Let --rw override --ro on a child path by emitting ro binds first 2026-04-12 14:36:07 +02:00
mrtoth 25f0037aab Filter environment variables in both sandbox modes
Whitelist mode now clears the parent env and re-adds a small allowlist
(identity, terminal, locale, proxy, non-GUI XDG, vendor prefixes).
Blacklist mode strips cloud credentials, backup passphrases, dangling
socket pointers, and anything matching *_TOKEN, *_SECRET, *_PASSWORD,
*_PASSPHRASE, *_API_KEY, *_PRIVATE_KEY, *_CLIENT_SECRET; vendor prefix
carve-outs keep ANTHROPIC_API_KEY and friends.

Users can override via --setenv KEY=VALUE and --unsetenv KEY (and the
corresponding TOML keys), or opt out of the built-in policy entirely
with --no-env-filter.
2026-04-08 09:22:11 +02:00
mrtoth 12644ae31e Apply a seccomp-BPF syscall allowlist by default
Derived from Podman's default profile, stripped of capability-conditional
rules (we never grant capabilities), argument filters, and the explicit
EPERM block. Dangerous syscalls (mount, unshare, ptrace, bpf,
perf_event_open, io_uring_*, keyctl, kexec_*, ...) fall through to the
default ENOSYS action, which also keeps glibc's clone3 -> clone fallback
working. x86_64 and aarch64 are supported; other archs error out.

Toggle with --seccomp / --no-seccomp or seccomp = <bool> in config.
2026-04-08 08:34:34 +02:00
mrtoth 8010e9102e Allow disabling boolean flags from the CLI
Pair --hardened, --dry-run, and --unshare-net (renamed from --no-net)
with negation counterparts so a CLI invocation can override a truthy
config-file or profile value.
2026-04-08 00:22:50 +02:00
mrtoth 83bd4305c7 Bind symlinked rw/ro paths at the user-written destination
Canonicalizing rw/ro paths in the config layer resolved symlinks before
the sandbox was built, so a symlinked entry only appeared at its
target's location -- never at the path the user wrote. Stop
canonicalizing rw/ro at the config layer and instead resolve only the
source side of the bind in sandbox.rs.
2026-04-07 17:45:38 +02:00
mrtoth 8ecba5d6dc Add option to pass through arguments to brwap, use shlex for dry-run 2026-04-04 08:51:08 +02:00
mrtoth c7c4c673cb Add mask option to hide paths/files from sandbox 2026-04-01 23:19:08 +02:00
mrtoth 0119834d5a Implement config file parsing and precedence with CLI 2026-03-31 01:22:08 +02:00
mrtoth f1d7a14b8d Ensure root filesystem is always read-only inside sandbox
Whitelist mode's implicit bwrap root was a writable tmpfs, letting the
sandboxed process create files and directories anywhere not covered by
an explicit ro mount. This was not an issue in blacklist mode due to
--ro-bind / / covering that case.

This patch adds --remount-ro / before any other mount to make the base
layer read-only in both modes.
2026-03-29 16:50:59 +02:00
mrtoth 5fc7eb3c11 Consolidate whitelist mode setup into add_whitelist_mode 2026-03-25 23:43:48 +01:00
mrtoth 82f84247f1 Rework handling of /run and ${RUNUSER} in blacklist mode 2026-03-25 22:48:39 +01:00
mrtoth 0bd91ffad2 Add /sys to whitelist mode 2026-03-25 22:22:35 +01:00
mrtoth dccf2309a5 Add --new-session to bwrap invocation 2026-03-25 22:15:21 +01:00
mrtoth ada9da7ae7 Reject empty HOME envvar 2026-03-20 21:43:08 +01:00
mrtoth 94535b20d3 Fix blacklist bind mount order 2026-03-20 21:02:48 +01:00
mrtoth 826c6d5531 Add ~/.claude.json to agent paths and use --bind-try 2026-03-20 20:41:24 +01:00
mrtoth 50dafb4c37 Fix read-only /dev, /proc, /tmp, /var/tmp, /run in blacklist mode 2026-03-20 20:40:57 +01:00
mrtoth c8e0d4813a Use --ro-bind-try for system files in whitelist mode 2026-03-20 19:29:53 +01:00
mrtoth bf53d92d49 Initial commit 2026-03-20 18:40:08 +01:00