Files
patrickandClaude Opus 5.5 f9d9660f71
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
Give the backup unit network access so its heartbeat ping can leave
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>
2026-10-31 14:58:51 -04:00

2.7 KiB

Security notes

← kernelwatch

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 a Retry-After header, 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 the Retry-After and retries, so running systemctl start kernelwatch-agent twice in a row just pauses briefly. Set it to 0 to 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 setuid snap-confine can't run under them (tested: NoNewPrivileges=yes fails with "cannot change profile for the next exec call"). It only runs canonical-livepatch status.
  • needrestart runs in a separate root unit with PrivateNetwork=yes, a capability set of just CAP_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 own apt-daily.service, but sandboxed: no access to home directories, devices or kernel settings. apt drops to its _apt user for the downloads, and nothing gets installed.
  • The server's timer units (alert check, nightly backup, backup-failure notice) run as the kernelwatch user with no capabilities and a syscall filter, limited to Unix and IP sockets. They need outbound network access for ntfy and the heartbeat pings, so PrivateNetwork= isn't an option there; tests/test_install.py enforces 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 through LoadCredential= 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=Strict cookies, 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.