Skip to main content

sandbox/profiles/
minimal.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! The minimal base profile.
5
6use crate::Builder;
7use crate::Network;
8use crate::Profile;
9use crate::Syscalls;
10
11/// A conservative starting profile that a worker widens for its own needs.
12///
13/// It grants read + execute on `/bin` and `/lib` (so a dynamically linked
14/// binary can start), denies all networking, and installs the seccomp
15/// dangerous-syscall baseline ([`Syscalls::Deny`] with no extras) — blocking
16/// namespace-escape and kernel-CVE syscalls such as `mount`, `unshare`,
17/// `pivot_root`, and `bpf`. Because every profile derives from
18/// [`Profile::deny_all`], it also drops all capabilities. A worker typically
19/// starts from here and chains further grants before building:
20///
21/// ```
22/// use sandbox::{Network, profiles};
23///
24/// let profile = profiles::minimal()
25///     .name("my_worker")
26///     .read_exec("/usr/lib")
27///     .network(Network::Unrestricted)
28///     .build();
29/// ```
30pub fn minimal() -> Builder {
31    Profile::deny_all()
32        .name("minimal")
33        .read_exec("/bin")
34        .read_exec("/lib")
35        .network(Network::None)
36        .syscalls(Syscalls::deny(std::iter::empty::<&str>()))
37}