You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement Capsicum capability mode for the main, resolver, and logger
processes on FreeBSD, matching the existing pledge/unveil (OpenBSD)
and seccomp-bpf (Linux) sandboxing.
Each sandboxed process calls cap_enter() after initialization,
restricting it to operations on already-open file descriptors.
Per-fd rights are limited via cap_rights_limit() on IPC sockets.
Resolver: eagerly initializes DoT SSL context (CA bundle loading)
before cap_enter() since filesystem access is needed. c-ares channel
is initialized before cap mode; socket/connect/sendto for DNS queries
work on new fds which get full rights in capability mode.
Logger: enters capability mode in the PRIVILEGES handler, after all
initial sinks have been created. Pre-opens parent directories for
each file sink and stores dirfd per ChildSink. Log rotation on
SIGHUP uses openat() on the pre-opened dirfd. Syslog is
pre-connected before cap_enter().
Main: checks config for AF_UNIX listeners, fallbacks, and backends;
skips cap_enter() if any are found since connect()/bind() to Unix
socket paths require VFS lookups forbidden in capability mode.
Pre-opens config directory for SIGHUP reload via openat(), and temp
directory for SIGUSR1 debug dumps. Sets logger_parent_fs_locked
after cap_enter() so the parent does not attempt path-based opens
during reload.
Binder: not sandboxed with Capsicum because it must bind() AF_UNIX
paths for Unix domain socket listeners.
Build system detects cap_enter() and cap_rights_limit() on FreeBSD
and defines HAVE_CAPSICUM. All capsicum code is guarded by
__FreeBSD__ && HAVE_CAPSICUM ifdefs, compiling as no-ops elsewhere.
Set SNIPROXY_DISABLE_CAPSICUM=1 to bypass for debugging.
Copy file name to clipboardExpand all lines: README.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,6 +72,7 @@ Features
72
72
spoofed sources
73
73
+**Privilege separation**: Separate processes for logging and DNS resolution
74
74
+**OpenBSD sandboxing**: pledge(2) and unveil(2) for minimal system access
75
+
+**FreeBSD sandboxing**: Capsicum capability mode with per-fd rights limiting
75
76
+**Input sanitization**: Hostname validation, control character removal
76
77
+**Comprehensive fuzzing**: Protocol fuzzers for TLS, DTLS, HTTP/2, XMPP,
77
78
Minecraft, hostname, address, config, listener ACL, IPC crypto, and resolver
@@ -571,6 +572,19 @@ All paths are collected from the loaded configuration, so custom locations work
571
572
as long as files/directories exist before launch. Helper processes are forked
572
573
(not exec'd) and inherit the master key for IPC encryption.
573
574
575
+
### FreeBSD Sandboxing
576
+
577
+
On FreeBSD, SNIProxy uses Capsicum capability mode to restrict each process after initialization:
578
+
579
+
-**Resolver process**: DoT SSL context is eagerly initialized before entering capability mode (since CA bundle loading requires filesystem access). The IPC socket is limited to read/write/send/recv/event rights.
580
+
-**Logger process**: Enters capability mode after privilege drop. Pre-opened directory fds allow log file rotation via `openat()` in capability mode. Syslog is pre-connected before `cap_enter()`. The IPC socket is limited to read/write/send/recv/event rights.
581
+
-**Main process**: Config directory and temp directory are pre-opened before entering capability mode. Config reload uses `openat()` on the pre-opened directory fd. Debug dumps use `openat()` on the pre-opened temp directory fd.
582
+
-**Binder process**: Not sandboxed with Capsicum because it must `bind()` AF_UNIX paths, which requires VFS lookups forbidden in capability mode.
583
+
584
+
The main process skips capability mode when any listener, fallback, or backend address is a Unix domain socket, since `connect()` and `bind()` to AF_UNIX paths require VFS lookups forbidden in capability mode. IP-only configurations (the common case) get full Capsicum protection. Adding new log file paths during SIGHUP reload is not supported in capability mode (existing log files can be reopened).
585
+
586
+
Set `SNIPROXY_DISABLE_CAPSICUM=1` in the environment to disable Capsicum sandboxing for debugging.
0 commit comments