Create root's trigger files as pi and tighten the root login check #145
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "root-boundary-hardening"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this PR does
Tightens what the root helpers do on the device's behalf:
pi, not root.agent train-now(also used by the dashboard's Train now and the auto-train on an algorithm switch) andremote-train nowused to create their request file as root and then chown it. They now go through a newpi_touchhelper inkestrel.sh: the file is created aspi(run_as_pi), withO_NOFOLLOW, and is born pi-owned, so nothing is chowned. A missing pi directory is created bypi_dir(install -d -o piunder its root-owned parent).agent importnow has root read the model andpiwrite it into the agent dir (temp file, renamed into place) instead ofinstall -o pi.[plugins.remote-train] agent_diris terminal-only (root_only), and root'srt_agent_diruses it only when it is an absolute path under/var/lib/kestrel/.plugins-ctl checkauth, behind[web] auth = "system"):nobody, with a login shell;/run/kestrel-auth(O_NOFOLLOW,flock, a 0700 directory it checks). After 5 failures in 10 minutes, checks are spaced out (0.25 s doubling, at most 4 s apart). A check that would have to wait more than 30 s is answered{"ok": false, "error": "busy"}at once. A success clears the count. If the state can't be used, checks go ahead without it rather than lock the owner out.updatesoptions root's engine reads are terminal-only:beta,timeoutandbackup_timeout_secondsjoinrepo,hostandtokenasroot_only. The Plugins page shows them read-only;sudo kestrel plugins set updates beta=truesets them. Root also clamps what it reads:timeoutto 5–120 s, andbackup_timeout_secondsto 30–3600 s (0 still means "no bound").Checklist
make lint(ansible--syntax-check,yamllint,shellcheck --severity=error, and the real-data check). The Lint workflow runs this on the PR.make test(thekestrel_pipytest suite and the real-data check's tests). The Test workflow runs this on the PR..envfiles, real names, personal emails, device serials, and no real captured or device data: SSIDs, MAC addresses, GPS coordinates, capture files, diagnostics bundles, logs, or screenshots of a real device — placeholders only. The real-data check catches MACs, emails, keys and capture files; real SSIDs, coordinates and screenshots are on you.docs/, and the on-device operator guide (GUIDE_MDinkestrel_pi/userguide.py) where it applies.Release impact
kestrel_pipackage,plugins/*.py, systemd units, the journald drop-in, a lib script already in the engine'sLIB_SCRIPTS, or the CLI.config.txt/cmdline, kernel modules, the base image or partition size,builder/config.json,builder/config.yml, theMakefile, the Release workflow (.forgejo/workflows/main.yml), a shipped config default (config.toml/default.conf), or a brand-new lib script.Notes for review
kestrel.sh(the CLI),plugins-ctl.pyandupdate-apply.py(both inLIB_SCRIPTS), and theupdatesandremote-trainplugins. No new lib script and no unit change: the backoff directory is created by the helper itself.beta = trueor a customagent_dirkeeps it; only who can change it changes.sudo kestrel plugins set updates beta=true|false. The docs and the on-device guide say so; the next beta checklist will too.test_root_writes.py(new) runspi_touch's snippet: it creates a missing file, leaves an existing one, and refuses a planted symlink with the target untouched. It also fails ifkestrel.shgains a root: >, pathchownorinstall -o piinto the agent dir or capture store, and checks those patterns still catch the old code.test_plugins_apply.py: the account policy (root, system accounts, nobody, no-login and unknown accounts are refused, each still costing one crypt); the backoff (free failures, growing spacing, "busy" past 30 s, forgetting after the window, refusing a symlinked state file or a shared directory, the owner still checked when the state is unusable); and the new root-only options refused through the socket.test_update_apply.py: the clamps.busy) follows in the next PR. Until then the dashboard showsbusyas a failed sign-in.🤖 Generated with Claude Code