mxc icon indicating copy to clipboard operation
mxc copied to clipboard

Bubblewrap: add a seccomp default-deny profile

Open kenchris opened this issue 1 month ago • 2 comments

Description of the new feature / enhancement

The Bubblewrap backend isolates with namespaces only. A sandboxed process can still call the full syscall surface, including calls that widen the kernel attack surface and that scripts do not need (io_uring_*, bpf, perf_event_open, userfaultfd, keyctl/add_key/request_key, ptrace/process_vm_*, module and kexec loading, the mount family). It also cannot restrict address families that no network rule covers: #936 (closed, tracked internally) describes AF_VSOCK bypassing proxy-only egress and names a seccomp filter on socket() as the fix.

This is the open roadmap item "Seccomp profile support" (Bwrap #27).

Proposed technical implementation details

  • A small reviewed table of denied syscalls, default action allow, verdict EPERM (tools fail the way they do under any container).
  • A family filter on socket()/socketpair() for families the workload has no use for (at least AF_VSOCK, see #936), comparing the argument with a 32-bit mask so the upper register bits cannot slip past it.
  • Foreign ABIs and the x32 bit answered with ENOSYS (no 32-bit socketcall gap).
  • Loaded with bwrap --seccomp FD.
  • Fail closed: if the filter cannot be built or loaded, refuse the run; never run unfiltered.
  • x86-64 first; aarch64 gets its own table.
  • The table leaves AF_UNIX socket creation allowed; a stricter variant that denies it is possible where nothing in the sandbox needs Unix sockets.
  • Config: opt out or extend the table through the planned BubblewrapConfig (roadmap item), if that is the preferred place.

Acceptance criteria:

  • A unit test runs the generated BPF program through a small interpreter and checks every table entry, the family cases, a sample of allowed calls, the x32 bypass and a foreign architecture.
  • An end-to-end check: a script calling io_uring_setup, perf_event_open and ptrace, and creating an AF_VSOCK socket, gets EPERM while ordinary Python and Node work; with the filter removed the same script succeeds (control).

We have a seccomp implementation of the syscall part in another bubblewrap-based sandbox and can contribute a PR for this item. (Its family filter does not exist yet; we are adding it.)

kenchris avatar Oct 07 '26 18:10 kenchris

@sohamdas2021 do you know if this still occurs?

bbonaby avatar Oct 26 '26 05:10 bbonaby

9. Soham Das (@SohamDas2021) do you know if this still occurs?

The AF_VSOCK/socket-family bypass was fixed by #1529, including the io_uring path that could bypass the direct socket() filter. So, #1443 was partially addressed and left open to track the broader seccomp syscall denylist (bpf, perf_event_open, ptrace, mount/module operations, etc.).

SohamDas2021 avatar Oct 26 '26 21:10 SohamDas2021