review: Astra round 3 (NOT READY) and census round 2 (ESCALATED 10), unedited
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+184
−0
docs/superpowers/reviews/CODEX-FINDINGS-census-named-unit-delivery-114-R2.md+104 −0docs/superpowers/reviews/CODEX-FINDINGS-named-unit-delivery-114-r3.md+80 −0
CI passed — run details
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-census-named-unit-delivery-114-R2.md b/docs/superpowers/reviews/CODEX-FINDINGS-census-named-unit-delivery-114-R2.md| new file mode 100644 |
| index 000000000..d625b017c |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-census-named-unit-delivery-114-R2.md |
| @@ -0,0 +1,104 @@ |
| +Round 1 escalations: |
| + |
| +- `runAdoptUnderRootRelease`: **not resolved** — production still reaches E1–E3 below. |
| +- `envFileNames`: **not resolved** — leaf-file checks improved; directory provenance remains unsettled. |
| +- `readDropIn`: **not resolved** — now uses `rootRead`, which retains E3. |
| +- `planStamped`: **not resolved** — declaration comparison fixed; file-reading protection remains incomplete. |
| +- `prepareStamped`: **not resolved** — declaration comparison fixed; directory protection remains incomplete. |
| +- `reapDropIns`: **resolved locally** — declaration removal controls drop-in removal; E2 survives through env-file cleanup. |
| +- `unitOpsBind`: **resolved** — removed and replaced by the required declaration comparison. |
| +- `SyncWithCallbacks`: **not resolved** — another writer and the env-file reaper bypass declaration authority. |
| +- Envelope `internal/appconfig`: **not resolved** — E1–E3. |
| +- Envelope `internal/host`: **not resolved** — production enables E1–E3. |
| + |
| +Reviewed `0db1966bfe019dc1482684bbb996e724237915b2` using the requested three-dot diff. `origin/main` was `4638a74076ce08ecef6d6f0b3fdca7de201a180f`; merge base was `9bcbab0f5646c11c7d05c9346dcfcea8c84f0751`. **10 escalated rows, covering three findings.** |
| + |
| +| Unit or envelope | Verdict | Reason | |
| +|---|---|---| |
| +| `cli.go:runRouteUnit` | approve | Line 1802 validates the proposed stamp before the existing write. | |
| +| `internal/host/agent.go:runAdoptUnderRootRelease` | escalate | Line 5275 enables the paths affected by E1–E3. | |
| +| `cli.go:runRouteHibernate` | approve | Line 1635 adds a refusal before the existing daemon check. | |
| +| `internal/appconfig/sync.go:UnitConfigApps` | approve | Lines 513–533 extend discovery without granting write authority. | |
| +| `internal/appconfig/sync.go:syncHostClaimed` | approve | Lines 564–585 preserve guarded writes; E1 concerns dispatch into this existing writer. | |
| +| `internal/appconfig/syncexec.go:AwaitingRestart` | approve | Lines 1163–1333 retain account, environment and owned-bundle narrowing. | |
| +| `internal/appconfig/syncexec.go:SyncExecWithCallbacks` | approve | Lines 713–749 keep the added `Stat` behind the route filter; it only reports a stale file. | |
| +| `cli.go:hibernateRail` | approve | Lines 1857–1862 only refuse hibernation on a named unit. | |
| +| `internal/appconfig/declarations.go:declarations.DeclaredBinding` | approve | Lines 111–120 enforce the unit/host/account/app comparison required by amended invariant A. | |
| +| `internal/appconfig/dropin.go:dirIsPlain` | approve | Lines 71–74 inspect the final entry without following it. | |
| +| `internal/appconfig/dropin.go:ensureDropInDir` | escalate | Lines 51–64 accept writable or foreign-owned directories before pathname writes; E3. | |
| +| `internal/appconfig/dropin.go:hasPending` | approve | Lines 126–128 use `Lstat` without reading the marker’s target. | |
| +| `internal/appconfig/dropin.go:unitDirs` | approve | Lines 134–153 enumerate the configured root and exclude symlinked child directories. | |
| +| `internal/appconfig/rootread_unix.go:rootRead` | escalate | Lines 43–61 omit directory ownership checks and do not pin directory traversal; E3. | |
| +| `internal/appconfig/stamped.go:StampShape` | approve | Lines 57–61 wrap the shared refusal predicate. | |
| +| `internal/appconfig/stamped.go:Stamped` | approve | Lines 25–28 classify route fields without performing privileged operations. | |
| +| `internal/appconfig/stamped.go:stampShapeReason` | approve | Lines 70–79 reject socket, missing-address and hibernating shapes. | |
| +| `internal/appconfig/stamped.go:stampedForDelivery` | escalate | Lines 48–49 let agent-controlled `Backing` divert a declared host to the other writer; E1. | |
| +| `internal/appconfig/stamped.go:unitDelivered` | approve | Lines 34–35 combine eligibility for discovery and fingerprints. | |
| +| `internal/appconfig/sync.go:finishHost` | approve | Lines 726–773 preserve extracted restart, claim and acknowledgement checks. | |
| +| `internal/appconfig/sync.go:prepareHost` | approve | Lines 605–703 preserve the previous basename, read, key-loss and rendering checks. | |
| +| `internal/appconfig/syncexec.go:BlockedStamps` | approve | Lines 1106–1141 compute scoped notices without disclosing another account’s hosts. | |
| +| `internal/appconfig/unitsync.go:applyStamped` | escalate | Line 377 consumes the insufficiently protected drop-in read; E3. | |
| +| `internal/appconfig/unitsync.go:planStamped` | escalate | Lines 95 and 181 inherit E3 through declaration and drop-in reads. | |
| +| `internal/appconfig/unitsync.go:prepareStamped` | escalate | Lines 247–287 inherit E3 through base-file reads and drop-in operations. | |
| +| `internal/host/unitops.go:daemonReload` | approve | Lines 115–120 execute fixed arguments. | |
| +| `internal/host/unitops.go:lockConfigSync` | approve | Lines 31 and 47–56 use the fixed production lock path. | |
| +| `internal/host/unitops.go:probeUnits` | approve | Lines 64–70 pass validated declared names separately; malformed batch attribution fails closed. | |
| +| `internal/host/unitops.go:systemctlRestartUnit` | approve | Lines 126–131 pass one validated unit argument without shell interpolation. | |
| +| `cli.go:runAdd` | approve | Lines 211–245 and 394–405 validate the resulting stamped shape before writing. | |
| +| `cli.go:unitRail` | approve | Lines 1838–1851 permit clearing and refuse unsupported proposed stamps. | |
| +| `internal/appconfig/routefingerprint.go:ConfigRouteFingerprints` | approve | Lines 79–85 add unit identity to change detection only. | |
| +| `internal/appconfig/sync.go:SyncWithCallbacks` | escalate | Lines 93–101, 309–346 and 350–364 allow the alternate writer and legacy reaper to bypass declarations; E1/E2. | |
| +| `internal/appconfig/syncexec.go:execRouteBase` | approve | Lines 875–879 exclude stamped routes from exec delivery. | |
| +| Envelope `.` | approve | Changed production functions add CLI refusals or additive notice decoding and rendering. | |
| +| Envelope `internal/appconfig` | escalate | Delivery integration and filesystem protection contain E1–E3. | |
| +| Envelope `internal/host` | escalate | Production wiring exposes E1–E3. | |
| + |
| +**E1 — P1: changing backing bypasses the declaration before replacing the same env file.** |
| + |
| +**Fault family:** invariant A — declaration authority must cover every writer of a declared unit’s configuration. |
| + |
| +The box agent controls registry rows; [registryowner.go:42](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/host/registryowner.go:42) assigns registry ownership to the service user. |
| + |
| +After successful delivery to a declared instance, change its `Backing` to `unit` and its `Account` or `App`, retaining its host. [stampedForDelivery:48](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/stamped.go:48) excludes that row from the declaration-controlled path. `SyncWithCallbacks` instead selects ordinary host work at lines 93–101 and calls `syncHostClaimed` at line 346. |
| + |
| +With claims disabled, that work permits the write. **Root renders the substituted app’s bundle and replaces `/etc/carlos/apps/<host>.env`** at [sync.go:573](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:573), without calling `DeclaredBinding`. |
| + |
| +The declared unit’s retained drop-in still names that exact file. Refusing a subsequent restart does not undo the replacement; its next start consumes the substituted configuration. |
| + |
| +Apply declaration authorization to every writer of a declared host’s env path. The witness should deliver a declared instance, then change backing together with account/app and assert that its env bytes remain unchanged. |
| + |
| +**E2 — P1: registry deletion still authorizes removal of a declared unit’s env file.** |
| + |
| +**Fault family:** the same declaration-authority invariant as E1. |
| + |
| +Delete a declared route while retaining any unrelated registry row. `reapDropIns` correctly preserves the declared unit’s drop-in. However, [SyncWithCallbacks:359](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:359) subsequently calls the existing `reap` when claims are disabled. |
| + |
| +That function derives liveness solely from registry hosts and removes absent hosts’ env files at [sync.go:411](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:411). **Root deletes configuration that the still-declared unit’s drop-in continues to load.** An unreadable declaration file does not prevent this cleanup either. |
| + |
| +The new witness at [unitsync_test.go:577](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/unitsync_test.go:577) deletes its only registry row. That triggers the empty-registry return, and its assertion checks the drop-in rather than the env file. |
| + |
| +Apply declaration authority to env-file cleanup too. Test deletion with another registry row present, checking both files, including when declarations cannot be read. |
| + |
| +**E3 — P1: the reader validates the leaf file without establishing protected directory traversal.** |
| + |
| +**Fault family:** invariant C — privileged reads must not follow paths an agent can replace. |
| + |
| +[rootRead:43](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/rootread_unix.go:43) checks directories with `Lstat` for type only. It neither checks their ownership and writable modes nor retains directory descriptors. Line 61 then resolves the complete pathname again. Only the final file descriptor receives ownership and mode checks. |
| + |
| +Consequently: |
| + |
| +- A root-owned `0600` file inside an agent-writable directory passes, although the agent can rename or remove its directory entry. |
| +- An intermediate directory can change between inspection and opening; final-component `O_NOFOLLOW` does not protect that traversal. |
| +- Ancestors above the configured directory are not checked. |
| + |
| +Removing an accessible declaration entry becomes “no declarations” at [declarations.go:66](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/declarations.go:66), which authorizes reaping. For drop-ins, `ensureDropInDir` also accepts writable directories before the pathname-based pending-marker and temporary-file writes. |
| + |
| +This remains an **unsettled provenance finding**, not evidence that a deployed `/etc` directory is currently agent-writable. The diff does not exclude those layouts. The previous release binding reader uses `rootstate.OpenTrustedFile`, whose [descriptor traversal](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/rootstate/state_linux.go:24) checks every ancestor’s ownership and mode. |
| + |
| +Preserve that protection in the shared reader and establish protected parent directories before writes. Add witnesses for writable parents, symlinked ancestors and intermediate-directory replacement. |
| + |
| +These findings retain the previous authority and filesystem-provenance fault families; the census review does not reset the branch’s review budget. |
| + |
| +No files changed, no subagents or tests ran, and `GOCACHE` was untouched. Posting the verdicts to #280 failed because the sandbox denied network access. |
| + |
| +ESCALATED (10) |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-named-unit-delivery-114-r3.md b/docs/superpowers/reviews/CODEX-FINDINGS-named-unit-delivery-114-r3.md| new file mode 100644 |
| index 000000000..8c44bc68a |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-named-unit-delivery-114-r3.md |
| @@ -0,0 +1,80 @@ |
| +Reviewed `0db1966bfe019dc1482684bbb996e724237915b2` using `origin/main...0db1966`; merge base remains `9bcbab0f5646c11c7d05c9346dcfcea8c84f0751`. Round 3 of 3. |
| + |
| +- **R2 P1-1 — Partly resolved:** direct account/app substitution is refused, but changing backing bypasses the declaration check. |
| +- **R2 P1-2 — Partly resolved:** rejected re-stamps preserve the drop-in; registry deletion can still remove its env file. |
| +- **R2 P1-3 — Partly resolved:** previous grammar counterexamples are refused; accepted Unicode noncharacters still make systemd reject the base file. |
| +- **R2 P2-4 — Resolved:** declaration binding no longer invokes the deployment-wide bucket inventory. |
| +- **R2 P2-5 — Resolved:** stamped notices explicitly check the required default bundle despite an explicit `exec_delivery`. |
| +- **Census E1 — Partly resolved:** declaration identity checks exist, but another writer can replace the same env file without them. |
| +- **Census E2 — Partly resolved:** drop-in retention follows declarations; env-file retention still follows registry rows. |
| +- **Census E3 — Partly resolved:** the three delivery readers use `rootRead`, but directory provenance and race protection remain incomplete. |
| + |
| +1. **P1 — Invariant A: changing backing bypasses authorization for an already-delivered env file.** |
| + |
| + [stamped.go:48](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/stamped.go:48) excludes `Backing=unit` from declaration-gated delivery. Such rows reach `syncHostClaimed` through [sync.go:346](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:346), which writes the same `<host>.env` without `DeclaredBinding` ([sync.go:576](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:576)). |
| + |
| + After legitimate delivery to `relay.service`, a box agent can change that host’s account/app and set `Backing=unit`. With host claims disabled, root replaces the env file with the substituted app’s config. The declaration retains the original unit’s drop-in, so that service consumes the substituted file on its next start. Refusal by the subsequent restart callback cannot undo the write. |
| + |
| + **Fix:** protect declared hosts’ env files before dispatching to either writer. A backing change or cleared stamp must not bypass the declaration’s identity check. Add a witness starting from successful stamped delivery, then changing backing and account/app. |
| + |
| + **Fault family:** registry-controlled classification bypasses root authorization over a named unit’s config. |
| + |
| +2. **P1 — Invariant A: registry-only cleanup deletes a declared unit’s env file.** |
| + |
| + After declaration-based drop-in reaping, [sync.go:362](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:362) still invokes the ordinary env reaper. Its retention set contains only registry hosts ([sync.go:411](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:411)); absent hosts’ files are removed at [sync.go:436](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:436). |
| + |
| + Delete a delivered host’s registry row while leaving another row present. Its declaration and drop-in survive, but its env file disappears. The next service start loses its delivered configuration. The new deletion witness misses this because it empties the registry, triggering the early return, and checks only the drop-in. |
| + |
| + **Fix:** include declared hosts in env-file retention and refuse destructive cleanup when declaration authority is unknown. Test deletion with an unrelated row remaining, asserting both files survive. |
| + |
| + **Fault family:** registry absence independently authorizes removal of declared-unit configuration. |
| + |
| +3. **P1 — Invariant A: checks before mutations reuse stale declarations.** |
| + |
| + [unitsync.go:95](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/unitsync.go:95) loads declarations once. Preparation, reaping and restart consult that same map at [unitsync.go:227](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/unitsync.go:227), [unitsync.go:329](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/unitsync.go:329) and [unitsync.go:419](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/unitsync.go:419). |
| + |
| + If an operator revokes or reassigns a declaration during the intervening bucket reads, root still writes and restarts using the former authorization. Conversely, a declaration added after planning does not protect an existing marked drop-in from reaping. Calling the decider again does not refresh its evidence. |
| + |
| + **Fix:** revalidate declaration contents through `rootRead` at mutation boundaries and abort on changes; serialize declaration replacement with the config transaction to close the remaining check/action race. Add witnesses changing declarations during the first probe and before restart. |
| + |
| + **Fault family:** authorization must remain valid through the effect it permits. |
| + |
| +4. **P1 — Invariant B: accepted UTF-8 can cause systemd to discard the entire base file.** |
| + |
| + [baseenv.go:88](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/baseenv.go:88) uses Go’s `utf8.Valid`; subsequent checks permit Unicode noncharacters in values. |
| + |
| + A file containing `CONSOLE_DB=/data/base.db`, followed by `EXTRA=` and U+FDD0, passes this grammar. I verified the actual installed systemd 257 `load_env_file` function in memory: it returns `-EINVAL` with **no assignments**. The ordinary ASCII control succeeds. U+FFFF produces the same failure. |
| + |
| + Because [dropin.go:44](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/dropin.go:44) makes the base file optional, systemd skips the failed file and can start the service without its bootstrap configuration. This error handling is explicit in [https://github.com/systemd/systemd/blob/v257/src/core/execute.c#L808-L812](https://github.com/systemd/systemd/blob/v257/src/core/execute.c#L808-L812). |
| + |
| + **Fix:** reject systemd-invalid Unicode noncharacters before delivery, retaining the strict-subset approach. Add differential witnesses covering U+FDD0–U+FDEF and each plane’s U+FFFE/U+FFFF. |
| + |
| + **Fault family:** the guard and systemd must agree on assignments and file acceptance. |
| + |
| +5. **P2 — Invariant C: directory provenance is not established by `rootRead`.** |
| + |
| + [rootread_unix.go:41](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/rootread_unix.go:41) begins at the configured directory, checks directory type but not ownership or writable modes, then opens the complete pathname at [rootread_unix.go:61](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/rootread_unix.go:61). Ancestors above the configured directory are unchecked; `O_NOFOLLOW` protects only the final component. |
| + |
| + On a layout with an agent-writable parent, a checked directory can be replaced between `Lstat` and `Open`. A root-owned final file still passes `Fstat`, despite being selected through the substituted path. An agent-owned base directory also permits removing or substituting root-owned file entries. |
| + |
| + Bootstrap normally creates `/etc/carlos` and the system unit directory with mode `0755`; the explicit agent ownership grants cover `/data` and `/run/carlos`. I found no evidence that the fleet’s current `/etc` ancestry is agent-writable. This remains an **unsettled provenance finding**, not a demonstrated fleet exploit. |
| + |
| + **Fix:** anchor traversal in directory descriptors, reject symlinks throughout resolution, and establish trusted ownership and permissions for the directory chain. Add writable-parent and directory-swap witnesses. |
| + |
| + **Fault family:** a trusted final inode does not establish trusted pathname resolution. |
| + |
| +6. **P2 — Invariant A: malformed declaration-file suffixes are ignored.** |
| + |
| + [declarations.go:77](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/declarations.go:77) performs one JSON decode without requiring EOF. |
| + |
| + A file containing `{"schema":1,"units":[]}garbage` is accepted as declaring nothing. Reaping can then remove marked drop-ins, although the declaration file is invalid and should authorize no cleanup. The existing release reader explicitly rejects trailing input. |
| + |
| + **Fix:** require EOF after the first document, while continuing to accept the existing `addr` and `health` fields. Test malformed trailing bytes and a second JSON document, asserting no delivery or reaping. |
| + |
| + **Fault family:** invalid authority data must fail closed. |
| + |
| +No files changed or subagents were used. Targeted Go tests could not start because the read-only sandbox refused Go’s temporary build directory. `GOCACHE` remained unset; no full suites ran. |
| + |
| +The P1s have **two causes**: incomplete enforcement of declaration authority, and remaining parser-acceptance disagreement. Upfront refusal can close the affected cases; withholding named-unit delivery removes this branch’s new exposure. Round 3 is exhausted, and another review round requires Paul’s approval. |
| + |
| +**NOT READY** |
| \ No newline at end of file |