Acts on the 2026-08-05 host security review. 36 of its 38 findings; the two exceptions are recorded below and in the review doc. The review's headline is that `plugin_may_access` was the one authorization gate in the system that was allow-by-default — a hand-maintained denylist of route prefixes, where every sibling gate is deny-by-default. Its own doc comment names the two capabilities it exists to withhold, and both were reachable one route over, because ~1450 commits of new routes were added and the list was never one of the things anyone remembered to update. So the gate is now an allowlist, and a test walks the live route table and fails the build for any route that has not been deliberately classified for both non-admin lanes. That test is the actual fix: it is what stops the next route from arriving pre-authorized. Route reachability and field authority turned out to be different questions. A provider plugin has to be able to reconcile its own library entries — that is what a scanner plugin IS — but `prep` and a `command` launch inside that payload are handed to `/bin/sh -c` as the host user, and every execution site documents them as operator-typed. Requests now carry the lane that authorized them, and those two fields are refused to everyone but the operator's own token. The art proxy read any absolute path off disk in the host process, which on Windows is LocalSystem, from a path the plugin lane could write and then read back — so it yielded `mgmt-token`, which is full admin. It now serves only real images (extension AND magic bytes, so a renamed secret fails), only from inside an allowed root, only after canonicalization, and never over UNC; and a path it would refuse to serve can no longer be persisted in the first place. On Windows, the config-dir hardening was skipped exactly when it was needed — it ran only in the branch that CREATES host.env, so the case it was written for (a local user pre-created the directory and planted one) was the one case it never ran in. It is now unconditional and first, an existing host.env is re-owned, and the inheritable OWNER RIGHTS ACE that kept an attacker's files theirs after the directory was re-owned is gone. The identity and token readers were hardening the directory only on the path that GENERATED a new secret, so a planted cert/key or token was adopted verbatim and permanently; they harden before the first read now. `ensure_admin_only_source` is implemented. The 2026-07-05 audit recorded it as FIXED and it was in no commit in this repository's history — the local EoP it described was live, and it is the payload half of the config-dir chain above. Also: the three input planes are bounded and lossy like the mic plane on the same loop already was; Android's library client no longer accepts any publicly-trusted certificate for the pinned host; the usbip vhci nodes get their own group instead of riding on `input`, which every packaging scriptlet tells users to join; a registry URL can no longer inject a TOML table into bunfig.toml; the pairing cooldown is charged before the arming state is read, so armed/disarmed is no longer a free oracle; and the whole Low tier, of which the two worth naming are a clipboard MIME NUL that panicked the host on one control message, and an unauthenticated global logout that let any LAN peer sign the operator out on a loop. NOT fixed, deliberately: H-3 (plugin UIs framed allow-same-origin). Dropping allow-same-origin does not work: the document's origin goes opaque, its subresource requests are then cross-site, the SameSite=Lax session cookie is not sent, and every plugin asset 302s to /login. The "open in new tab" link is the same escalation with no iframe at all, so the sandbox attribute is not where this gets fixed either. It needs a second listener — a distinct origin that is still the same site — which changes the console's deploy model and wants on-glass validation. The mechanism and the dead end are written down at the iframe. H-6 registry authentication, whose other half lives in unom/infra. The in-repo halves are done: workflow_dispatch inputs no longer interpolate into run: blocks (one of them in the step holding UPDATE_MANIFEST_KEY), and the syft installer is pinned to its tag instead of main. Digest pinning is left until the registry is authenticated, because a tag — content-keyed or not — can simply be overwritten while anonymous pushes are accepted. M-5 is half done: the oracle is closed, but binding the arming window needs the console to learn the fingerprint first, which is a knock-then-bind flow rather than an edit. Verified: cargo fmt --all --check clean; cargo check --all-targets green on Linux and on Windows (confirmed non-vacuous — a planted type error in windows/install.rs fails the build); scripts/xcheck.sh windows check green; cargo test -p punktfunk-host --bins 416 passed, the single failure being gamestream::stream::tests::sender_delivers_batches, the known qemu-environmental UDP-loopback flake that fails identically on clean main in the same container; cargo test -p pf-clipboard 13 passed; web console typechecks.
84 lines
3.8 KiB
Bash
84 lines
3.8 KiB
Bash
#!/bin/sh
|
|
# Privileged display-manager verbs for the punktfunk managed gamescope takeover.
|
|
#
|
|
# On DM-autologin boxes whose display manager does not survive a masked session unit (Nobara's
|
|
# plasmalogin, unknown DMs), taking the Gaming Mode session over means stopping the display
|
|
# manager for the length of the stream and restarting it afterwards — root-only operations. The
|
|
# host invokes this helper via pkexec under its own polkit action
|
|
# (io.unom.punktfunk.dm-helper.policy, installed by the packages), the same mechanism these
|
|
# distros use for their own session switching (Nobara's os-session-select).
|
|
#
|
|
# The unit is NEVER caller-controlled: it is derived here from the display-manager.service alias
|
|
# symlink, so the polkit grant's blast radius is exactly "the box's own display manager" — a
|
|
# local-seat operation, not arbitrary unit management.
|
|
set -eu
|
|
|
|
# The polkit action has to stay permissive (`allow_any=yes`): the host commonly runs as a LINGERING
|
|
# user unit, which has no logind session at all, so polkit classifies it under `allow_any` and any
|
|
# stricter default would make the takeover unauthorizable in its primary deployment. The cost of
|
|
# that is that polkit alone authorizes *every* local subject — a seatless ssh session, a service
|
|
# account — to run this as root (2026-08-05 review L-14).
|
|
#
|
|
# So the authorization decision is made HERE instead, where the caller is knowable: pkexec sets
|
|
# PKEXEC_UID from the authenticated caller, and only a member of the `punktfunk` group (created by
|
|
# the packages) may proceed. That keeps the sessionless host working while making membership of one
|
|
# explicit group — not merely "has a local uid" — the thing that grants these verbs.
|
|
require_authorized_caller() {
|
|
uid=${PKEXEC_UID:-}
|
|
[ -n "$uid" ] || {
|
|
echo "pf-dm-helper: no PKEXEC_UID in the environment — refusing to run unauthenticated" >&2
|
|
exit 1
|
|
}
|
|
user=$(getent passwd "$uid" | cut -d: -f1) || user=
|
|
[ -n "$user" ] || {
|
|
echo "pf-dm-helper: PKEXEC_UID $uid resolves to no local user — refusing" >&2
|
|
exit 1
|
|
}
|
|
# `id -nG` lists the primary group too, so a user whose primary group IS punktfunk also passes.
|
|
for g in $(id -nG "$user" 2>/dev/null); do
|
|
[ "$g" = punktfunk ] && return 0
|
|
done
|
|
echo "pf-dm-helper: user '$user' is not in the 'punktfunk' group — refusing." >&2
|
|
echo " Grant it with: sudo usermod -aG punktfunk $user (then re-login)" >&2
|
|
exit 1
|
|
}
|
|
|
|
require_authorized_caller
|
|
|
|
dm_unit() {
|
|
target=$(readlink /etc/systemd/system/display-manager.service) || {
|
|
echo "pf-dm-helper: no display-manager.service alias — no display manager to manage" >&2
|
|
exit 1
|
|
}
|
|
basename "$target"
|
|
}
|
|
|
|
case "${1-}" in
|
|
stop)
|
|
exec systemctl stop "$(dm_unit)"
|
|
;;
|
|
restore)
|
|
dm=$(dm_unit)
|
|
# reset-failed first: a relogin loop may have tripped the unit's start limit, and a plain
|
|
# restart would be refused until the accounting is cleared.
|
|
systemctl reset-failed "$dm" 2>/dev/null || :
|
|
exec systemctl restart "$dm"
|
|
;;
|
|
linger)
|
|
# Keep the caller's own `systemd --user` manager alive across the stop. Stopping the display
|
|
# manager ends the user's last login session, and logind then stops user@<uid>.service after
|
|
# UserStopDelaySec (10s by default) — which takes the host that asked for the takeover with
|
|
# it, so nothing is left to restart the display manager and the box stays dark. Lingering is
|
|
# what breaks that dependency (the setup docs already ask for it).
|
|
#
|
|
# The user is NEVER caller-named: PKEXEC_UID is set by pkexec from the authenticated caller,
|
|
# so this grant enables lingering for that caller alone. (Its presence is already checked by
|
|
# `require_authorized_caller` above, which also proved the caller is in the punktfunk group.)
|
|
exec loginctl enable-linger "${PKEXEC_UID}"
|
|
;;
|
|
*)
|
|
echo "usage: pf-dm-helper stop|restore|linger" >&2
|
|
exit 2
|
|
;;
|
|
esac
|