priv

package
v2.7.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func LockDownSecretPaths(paths ...string) error

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

func LockDownSecretPathsStrict(paths ...string) error

LockDownSecretPathsStrict enforces LockDownSecretPaths and returns any symlink, hardlink, or permission-lockdown error.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL