CI / tests (Python 3.11) (pull_request) Successful in 28s
CI / tests (Python 3.10) (pull_request) Successful in 29s
CI / tests (Python 3.12) (pull_request) Successful in 25s
CI / tests (Python 3.13) (pull_request) Successful in 26s
CI / lint (pull_request) Successful in 2s
kernelwatch-backup.service still had PrivateNetwork=yes and
RestrictAddressFamilies=AF_UNIX from before scheduled-backup pinged
backup_heartbeat_url. Every nightly ping failed DNS inside the sandbox
("heartbeat request failed (URLError)"); the backup itself succeeded, so
the only symptom was the heartbeat monitor going down after a day.
Allow AF_INET/AF_INET6 like the alerts unit, and add a test that every
unit running a command that sends requests (check-alerts,
scheduled-backup, notify-backup-failure) keeps network access.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2.7 KiB
2.7 KiB
Security notes
How kernelwatch is locked down, and what it deliberately can't do.
- Host identity comes from the token, not the payload. A host can only report as itself. Tokens are 256-bit random values; only their SHA-256 is stored.
- Report rate limit. A report arriving less than
report_min_interval_seconds(default 30) after the host's previous one gets HTTP 429 with aRetry-Afterheader, and isn't stored. So a stuck agent or a leaked token can't flood the database or push real history off the host page. The agent's curl waits out theRetry-Afterand retries, so runningsystemctl start kernelwatch-agenttwice in a row just pauses briefly. Set it to0to disable. - Livepatch status runs in a separate root unit with no network access and a
read-only filesystem. It has no capability bound, syscall filter or
NoNewPrivileges, because the snap's setuidsnap-confinecan't run under them (tested:NoNewPrivileges=yesfails with "cannot change profile for the next exec call"). It only runscanonical-livepatch status. - needrestart runs in a separate root unit with
PrivateNetwork=yes, a capability set of justCAP_SYS_PTRACE+CAP_DAC_READ_SEARCH(to read other processes' memory maps), a read-only filesystem except/run/kernelwatch, and-r l(list, never restart). - apt-get update (with
--with-apt-update) runs as root with network access, like apt's ownapt-daily.service, but sandboxed: no access to home directories, devices or kernel settings. apt drops to its_aptuser for the downloads, and nothing gets installed. - The server's timer units (alert check, nightly backup, backup-failure
notice) run as the
kernelwatchuser with no capabilities and a syscall filter, limited to Unix and IP sockets. They need outbound network access for ntfy and the heartbeat pings, soPrivateNetwork=isn't an option there;tests/test_install.pyenforces that. - The agent runs as a throwaway unprivileged user (
DynamicUser=yes) with no capabilities, a read-only filesystem view and a syscall filter. The token reaches it throughLoadCredential=and goes to curl on stdin, so it never appears in a process listing. - The dashboard uses scrypt-hashed passwords, server-side sessions,
HttpOnly+Secure+SameSite=Strictcookies, an Origin check on form posts, per-IP login rate limiting, and a strict CSP. Everything a host reports is HTML-escaped. - It's read-only by design. The server can't make hosts do anything. Adding remote actions (like "reboot this host") would turn it into a remote-execution system; think hard before doing that.