Documentation
¶
Overview ¶
Package priv implements irreversible root privilege dropping and pre-drop secret file lockdown on Linux containers. At startup (while still UID 0), LockDownSecretPaths enforces 0600 root:root on /data/options.json and 0700 root:root on /data; then DropRoot invokes PR_SET_NO_NEW_PRIVS + Setgroups([]) + Setgid(65532) + Setuid(65532) + PR_SET_DUMPABLE(0) across all Go runtime OS threads (AllThreadsSyscall6) before any network socket opens or Chromium subprocess spawns, guaranteeing VFS DAC blocks UID 65532 (and all child processes) from reading /data/options.json and marking /proc/<pid>/environ + /proc/<pid>/mem non-dumpable (`Dumpable: 0`) on every Linux kernel.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DropRoot ¶
func DropRoot() error
DropRoot permanently transitions UID/GID 0 down to unprivileged `65532:65532` (`nonroot`), sets `NO_NEW_PRIVS`, and marks the process non-dumpable (`PR_SET_DUMPABLE=0`).
func LockDownSecretPaths ¶ added in v2.5.4
LockDownSecretPaths restricts `/data` (`0700` owned by `0:0`) first and then restricts secret configuration files (such as Home Assistant `/data/options.json`, `0600` owned by `0:0`) while the process is still UID 0, right before DropRoot(). Uses `O_NOFOLLOW|O_CLOEXEC|O_NONBLOCK` + `Fstat` + `Fchown`/`Fchmod` on the opened file descriptor so concurrent symlink swaps or hardlinks (`nlink > 1`) can never redirect ownership or mode changes onto another inode.
func LockDownSecretPathsStrict ¶ added in v2.6.0
LockDownSecretPathsStrict enforces LockDownSecretPaths and returns any symlink, hardlink, or permission-lockdown error.
Types ¶
This section is empty.