plat/sandbox.rs#
Source: lib/plat/sandbox.rs
sandbox -- OS-level confinement that mirrors the permission manifest (docs/PERMISSIONS.md
"OS sandbox"), as defence in depth for the in-process policy (policy.rs): a bug or native
code can bypass `plat`, the kernel cannot be bypassed. Opt in with a `sandbox` (best effort)
or `sandbox strict` (refuse to start when the OS cannot enforce it) line in the manifest.
apply() install the sandbox for the active policy, once, at start-up (boot.rs,
before the app's own code runs); nothing without a `sandbox` line
status() -> Status what was applied (tests, a diagnostics page)
Linux: Landlock restricts the filesystem to the folders the manifest grants plus the system
paths the library reads (ABI detected, best effort on older kernels), and TCP bind / connect
to the manifest's ports (ABI 4+); seccomp-bpf denies a list of dangerous syscalls (ptrace,
process_vm_*, kexec, module loading, mount, bpf, perf_event_open, userfaultfd, keyctl ...)
and execve when no program is allowed. Windows: process mitigation policies (image load,
extension points, dynamic code; strict adds child-process creation, strict handle checks are
deliberately not set: win_sandbox.rs). The browser and Android have no such API; apply() does
nothing there.
struct Statuswhat [apply] installed (the fields not relevant to this OS stay false / -1)level: u8-- 0 none, 1sandbox, 2sandbox strictlandlock_abi: i32-- Linux: the Landlock ABI the kernel reports (-1 = no Landlock)landlock_fs: bool-- Linux: the filesystem ruleset is enforcedlandlock_net: bool-- Linux: TCP bind / connect is restricted (Landlock ABI 4+)seccomp: bool-- Linux: the seccomp filter is installedexec_denied: bool-- execve is denied (no program allowed): Linux seccomp, Windows child-process policywin_mitigations: bool-- Windows: the process mitigation policies were setwin_dynamic_code: bool-- Windows: dynamic code is prohibited (no native plugins)
impl Status
const NONE: Status = Status { level: 0, landlock_abi: -1, landlock_fs: false, ...nothing appliedfn apply()(Linux) install the OS sandbox the active policy asks for (nothing without asandboxline); call once, before the app's own code and before any worker thread is startedfn apply()(Windows) install the OS sandbox the active policy asks for (nothing without asandboxline)fn apply()the browser and Android have no such APIfn status() -> Statuswhat [apply] installedfn status() -> Statusthe browser and Android install nothingfn denied_syscalls() -> &'static [usize](Linux) (Linux) the system calls the seccomp filter answers with EPERM; execve and execveat come on top when the manifest allows no program (sandboxtest calls every one of them)