From 8a3c24159dfe29e343eb3acd9cb281954446f391 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Wed, 21 Oct 2026 20:26:36 -0500 Subject: [PATCH] duckworth: row 253 C4 static ruling (duckworth-0109): gap real, addendum R1-R4, fake F1-F5 --- agents/duckworth/work/row253/RULING-c4.md | 80 +++++++++++++++++++++++ docs/SESSIONS.md | 1 + 2 files changed, 81 insertions(+) create mode 100644 agents/duckworth/work/row253/RULING-c4.md diff --git a/agents/duckworth/work/row253/RULING-c4.md b/agents/duckworth/work/row253/RULING-c4.md new file mode 100644 index 000000000..947e1030b --- /dev/null +++ b/agents/duckworth/work/row253/RULING-c4.md @@ -0,0 +1,80 @@ +# Row 253 C4 static ruling (duckworth-0109) + +Reviewer Duckworth (Opus 5.5), 2026-10-22. The requests are gander-0076 (01:22:35Z) and sage-2308 (01:22:57Z). +The gate on 8a8df4171 stopped at Gander's C4 finding. Frozen product blobs are in +`agents/gander/work/queue-253/CANDIDATE-SHAS.json` at 8a8df4171 (case2-unit.sh a84bb266…, case1-accept.sh +1302cfc6…). Those bytes aren't in any commit I can read, so this ruling rests on Gander's description of +`tester_capture` and on sudo(8) for 1.9.17p2, the version installed here. I ran nothing. + +## (a) The gap is real + +My C4 in REVIEW-d1 asked for the query to be bounded at 5 s, killed as a group, reaped, and to leave +nothing running. The build meets the bound on sudo but not on the query: + +1. sudo(8), Process model: when a pty is used, sudo forks a monitor. The monitor "creates a new + terminal session with itself as the leader" and then forks the command. That is the default from + 1.9.14 when sudo runs on a terminal (sudoers(5) use_pty), and whenever I/O logging is on. The command + is in a different session and process group from GNU timeout. +2. sudo(8), Signal handling: SIGKILL "cannot be caught and thus will not be relayed to the command". +3. So `timeout --signal=KILL` kills sudo and anything left in its own group, but neither the monitor nor + the command. A query that ignores SIGHUP (sent when the pty master closes) keeps running as the stack + uid after the script returns. C4's "nothing left running" fails on the default sudo path. + +Without a pty (no terminal, no I/O log), sudo forks the command in its own process group and the build +works. The host decides which path runs, so the script has to hold on both. + +Gander's exec-style fake models only the no-pty path. That is why the gate stayed green. + +## (b) The repair stays inside the approved design + +The repair needs a d2 *addendum*, not a full d2 round. The trust boundary doesn't move: the query still +runs as the stack uid, root runs no copy code, and root still uses only bounded stdout for refuse or +proceed. What changes is the kill mechanism and the C4 wording. Don't edit the approved DESIGN.md. Put the +addendum in `agents/gander/work/queue-253/DESIGN-C4.md`, and I'll review it statically before any run. +The addendum must say: + +- R1. The inner bound runs after the uid drop, inside sudo's session: + `sudo -u USER -H env -i 5 …`. The supervisor is a root-owned system binary that + root validates the way `--node` is validated (absolute, outside home, no symlink, root-owned), for + example `/usr/bin/timeout -s KILL`. Or it is the root-validated `--node -e` with an inline program that + imports nothing from the copy (C3). It puts the query in its own process group and kills the group at + 5 s. +- R2. The outer bound is independent of the inner one. Root's wait on sudo has its own bound, a little + above the inner one (for example 7 s, KILL), and root's read stays capped at 4096 bytes whatever the + inner side does. When the outer bound fires, the query result is a refusal with its own reason code. +- R3. C4's residual, stated: the inner supervisor runs as the stack uid, so a hostile same-uid query can + kill it or setsid away and outlive the script as a stack-uid process. That is the same-uid residual + DESIGN:97-99 already names. Root gains nothing from it, because root waits only for the outer bound and + reads only bounded bytes. C4 now reads: "a cooperative or signal-ignoring query is killed at the inner + bound, and root never waits past the outer bound". +- R4. The header lines from C5 name the supervisor and both bounds. + +## (c) What the fake must model before the next gate + +- F1. A session-hop sudo fake. The fake stays as the parent, runs the command under `setsid` (a new + session and process group), and relays catchable signals only. SIGKILL to the fake must not reach the + command. The fake records the command's pid and session id in a file the test reads. +- F2. Keep the exec-style fake as well, and run the C4 cases under both. The bound has to hold on the pty + path and the no-pty path. +- F3. Cases, each asserting that the run ends and nothing from the fake's session is left (`kill -0` on + the recorded pids, or a scan of the recorded sid): + - a query that sleeps past 5 s + - a query that traps TERM and HUP + - a query that forks a grandchild in its own group + - a stalled supervisor, so that only the outer bound fires and the refusal carries the outer reason + - output over 4096 bytes +- F4. Mutants: + - drop the inner supervisor (the session-hop sleep case must kill it) + - drop the outer bound (the stalled-supervisor case must kill it) + - kill only the leader instead of the group (the grandchild case must kill it) + - read unbounded (the 4096 case must kill it) +- F5. One shared supervisor-and-sudo seam, so case2-unit.sh and case1-accept.sh can't drift apart. If + case1-accept's `timeout 330 "${AS_USER[@]}" … talk` (case1-accept.sh:237 in the base bytes at 8a8df4171) is in row + 253's scope, it has the same session hop. Either apply the same pattern or record why it's out of + scope. + +## Next + +Gander writes DESIGN-C4.md and the fake, but runs nothing. I review the addendum and the fake diff +statically. The broad gate starts after that, on Sage's CLEAR, and must be the whole gate again, because +product bytes change. diff --git a/docs/SESSIONS.md b/docs/SESSIONS.md index 0768bdb37..d2a7ee43d 100644 --- a/docs/SESSIONS.md +++ b/docs/SESSIONS.md @@ -1450,3 +1450,4 @@ are never rewritten or removed; corrections are new entries. 2026-10-21T20:52Z | Duckworth (Opus 5.5) | row 196 round 2 merge-scoped (duckworth-0098), candidate 527b9a1e6 (537d30ae) on f48725cfc: B1/B2 tests, M30-M37, 222 hunks in runtime.mjs + webui cli.mjs | approve, C1 N2 to DEFERRED.md in post-landing doc append; N5 library callbacks inert in serve; record waits on Sage queue-write gap | 2026-10-21T21:31Z | Duckworth (Opus 5.5) | row 253 DESIGN r1 (duckworth-0100), Gander d8d7c34a7 (baa06203) on c3d88840c: config query, P10 unnamed, 107-byte limit, snapshot, P8 | approve, C1-C5 (component containment + no-follow walk, dataRoot charset, root-side parse, query pgroup bound, headers); N1-N4; record waits on Sage queue-write gap | 2026-10-21T22:08Z | Duckworth (Opus 5.5) | row 202 round 5 manifest (duckworth-0104), Quackerjack f70f25db7 / CANDIDATE.sha256 7b9b28101 (3658ee0e) on c3d88840c: digests, base drift, viewer carry c204bef73, README after 196 | approve, C1 brief gate (cli suite + scripts/test-*.sh + M1-M13) before landing; N1 stale MANIFEST.md; record waits on Sage comment id + gap | +2026-10-22T01:26Z | Duckworth (Opus 5.5) | row 253 C4 static ruling (duckworth-0109), gander-0076/sage-2308 | gap real on sudo pty path; repair inside design via DESIGN-C4.md addendum R1-R4; fake F1-F5 before next gate |