toolchain: the supervised nix install's pkexec dies pre-auth in nix-develop envs (same defect as the primer's Finding M) #340

Closed
opened 2026-08-08 15:04:34 +00:00 by ben · 1 comment
Owner

internal/toolchain/installer.go:76 runs i.run(ctx, pkexec, "sh", "-c", OperatorInstallCommand()) with no SHELL sanitization. pkexec validates the invoking environment's SHELL against /etc/shells BEFORE prompting; nix develop exports a store-path bash that is never listed, so the supervised install exits 127 pre-auth in any nix-develop environment — the identical defect Finding M fixed for the primer (commit 9fcaf22), confirmed by grep as the only other production pkexec invocation.

Fix shape: mirror prime.go's elevatedPrime (env SHELL=/bin/sh carried on the invocation via env, no nested re-quoting) with the same style of discriminating test (recorded invocation asserts the sanitization sits before pkexec; red pre-fix). Unlike priming, the installer fails LOUD, so severity is lower — but it is the consent-gated install path (ADR 0125), and a 127 there blocks a nix-less host's founding. Consider whether the Finding N elevation bound belongs here too (an install prompt is NOT an optimisation — probably not; say why in the fix).

`internal/toolchain/installer.go:76` runs `i.run(ctx, pkexec, "sh", "-c", OperatorInstallCommand())` with no SHELL sanitization. pkexec validates the invoking environment's SHELL against `/etc/shells` BEFORE prompting; `nix develop` exports a store-path bash that is never listed, so the supervised install exits 127 pre-auth in any nix-develop environment — the identical defect Finding M fixed for the primer (commit `9fcaf22`), confirmed by grep as the only other production pkexec invocation. Fix shape: mirror `prime.go`'s `elevatedPrime` (`env SHELL=/bin/sh` carried on the invocation via `env`, no nested re-quoting) with the same style of discriminating test (recorded invocation asserts the sanitization sits before pkexec; red pre-fix). Unlike priming, the installer fails LOUD, so severity is lower — but it is the consent-gated install path (ADR 0125), and a 127 there blocks a nix-less host's founding. Consider whether the Finding N elevation bound belongs here too (an install prompt is NOT an optimisation — probably not; say why in the fix).
Author
Owner

Fixed in 8b053f0 (on origin/main).

internal/toolchain/installer.go:76 now runs the supervised install as env SHELL=/bin/sh pkexec sh -c … instead of a bare pkexec sh -c …. pkexec validates the calling process's $SHELL against /etc/shells before it prompts, and under nix develop $SHELL is a store-path bash that is never listed — so the unsanitised call exited 127 pre-auth on any nix-develop host, killing the consent-gated founding of a nix-less machine (ADR 0125) before the operator could authenticate. Carrying SHELL=/bin/sh via env (no nested re-quoting, sitting before pkexec so pkexec reads it from its own environment) reaches the prompt.

Deliberately no elevation-timeout bound (the Finding N question in the brief): this is the consent-gated install itself, not a best-effort optimisation — the operator's authentication is the point, not a cost to cap — and it already fails loud on a non-zero exit (ADR 0100). Rationale recorded in the code comment.

Evidence: TestInstallSanitisesShellBeforePkexec (records the invocation, asserts the sanitisation sits before pkexec; red before the fix, per the manifest's discriminating style); full internal/toolchain + internal/founding suites green; gofmt/build clean; the repo pre-push hook ran the suites green on push.

Note on the brief's premise: this repo has no prime.go/primer (the "Finding M fix (commit 9fcaf22)" it cites to mirror is absent from main and all history — same phantom as #341). The defect and remedy here are self-contained, so the fix stands without it; the sibling hardening issue #341 (all-phantom) was routed to ready-for-human.

Fixed in `8b053f0` (on `origin/main`). `internal/toolchain/installer.go:76` now runs the supervised install as `env SHELL=/bin/sh pkexec sh -c …` instead of a bare `pkexec sh -c …`. pkexec validates the calling process's `$SHELL` against `/etc/shells` before it prompts, and under `nix develop` `$SHELL` is a store-path bash that is never listed — so the unsanitised call exited 127 pre-auth on any nix-develop host, killing the consent-gated founding of a nix-less machine (ADR 0125) before the operator could authenticate. Carrying `SHELL=/bin/sh` via `env` (no nested re-quoting, sitting before pkexec so pkexec reads it from its own environment) reaches the prompt. Deliberately **no** elevation-timeout bound (the Finding N question in the brief): this is the consent-gated install itself, not a best-effort optimisation — the operator's authentication is the point, not a cost to cap — and it already fails loud on a non-zero exit (ADR 0100). Rationale recorded in the code comment. Evidence: `TestInstallSanitisesShellBeforePkexec` (records the invocation, asserts the sanitisation sits before pkexec; red before the fix, per the manifest's discriminating style); full `internal/toolchain` + `internal/founding` suites green; gofmt/build clean; the repo pre-push hook ran the suites green on push. Note on the brief's premise: this repo has no `prime.go`/primer (the "Finding M fix (commit `9fcaf22`)" it cites to mirror is absent from `main` and all history — same phantom as #341). The defect and remedy here are self-contained, so the fix stands without it; the sibling hardening issue #341 (all-phantom) was routed to `ready-for-human`.
ben closed this issue 2026-08-08 15:36:40 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#340
No description provided.