From 3d149dbe42d584e70e413ff82eb663374641a3dd Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Fri, 4 Dec 2026 23:48:10 -0800 Subject: [PATCH] redteam: 48-row matrix green on 79375582b (0 failed) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The final regression for PR #390: all 48 rows PASS under matrix XTCP2_EXPECT control, including the three review-fix restructures (rt-11-10 BLOCKED, rt-11-11 CONFIRMED, rt-11-12 BLOCKED — each fork finished its expected verdict green, so the always-red-fork fix is confirmed end-to-end, not just solo). DoD row closed. --- docs/redteam-implementation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/redteam-implementation.md b/docs/redteam-implementation.md index bb2bb7032..679ab7dee 100644 --- a/docs/redteam-implementation.md +++ b/docs/redteam-implementation.md @@ -304,7 +304,7 @@ cap matrix, and ship the runbook. - [x] **Phase 5 part 2 complete (the capability rows)**: rt-5-3 **CONFIRMED** (35/35, `20261203T093134-e811a90f2-3244581` — **the blast-radius answer: a compromised daemon container is a host-trust domain in EVERY cap shape, including the minimum-cap recipe**: an 8-probe busybox battery (docker-cp'd into the shell-less scratch image and docker-exec'd — the takeover shape) run against four shapes — the deployed min recipe, the §29 compose shape (docker defaults + NET_ADMIN/SYS_ADMIN/SYS_CHROOT), `--privileged --pid host`, and a plain co-tenant — found host link state flappable and every mounted co-tenant netns enterable from all three daemon shapes (NET_ADMIN + SYS_ADMIN are the collector's own powers; caps cannot minimize them away), while what actually bounds mount and host-process ptrace on Ubuntu is the `docker-default` AppArmor profile (mount denied even with SYS_ADMIN; /proc/1 ptrace denied to non-same-profile targets) — `--privileged` (or `apparmor=unconfined`) removes that bound entirely, lifting mount, host-PID-1 environ, and insmod to the kernel; the min recipe's real win over the compose shape is dropping MKNOD/DAC_OVERRIDE/SETUID-class caps, and the plain co-tenant is denied every host-mutating probe. The full matrix is in `docs/security.md` "Blast radius of a compromised daemon container"), rt-5-4 **BLOCKED** (46/46, `20261203T102631-e811a90f2-3633767` — **the capability contract holds**: six one-cap-dropped daemons (`--cap-drop=ALL` + per-row adds, otherwise the exact victim.sh host-mode shape, each on its own loopback prometheus port and link-monitor baseline file — the baseline lock is per-file) measured per feature: dropping NET_ADMIN or SYS_ADMIN → exit 1 with the actionable message naming the cap (the all-dropped floor names both fatal caps after all three soft WARN lines); dropping SYS_PTRACE → runs, WARNs, the /proc-scan discovery goes fully blind (foundProc 5→0 per scan — ptrace_may_access + Yama ptrace_scope=1) while netns coverage survives via the /run/netns + /run/docker/netns bind mounts (found/start stays 5/scan — the init_capabilities.go claim "found stays at 1" is wrong in the docker shape; corrected in docs/security.md); dropping NET_RAW or SYS_RESOURCE → runs, WARNs, zero degradation (udp dests and io_uring are the only consumers); inet_diag, ethtool (the settings collector), the RDMA netlink backend, and the link monitor are unaffected by every soft drop. The matrix + minimum-cap recipe are in `docs/security.md` "Capability × feature matrix". Three more harness lessons surfaced on the way, all encoded in the scenario: `grep -q` on a pipe of a big variable is a SIGPIPE coin flip under pipefail (the rt-5-1 lesson's third shape — printf-dies-at-first-match; herestring or remote grep instead), an unanchored metric grep matches the exposition's `# HELP` line (line-anchor every probe), and busybox dispatches on argv[0] (a cp'd `bb` is "applet not found" — keep the name busybox)). **Final regression: 42/42 PASS, 0 failed on `d2307610a` (matrix run `20261203T164451-d2307610a`; the first 42-row run on `10b26a71e` was 41/42 — rt-11-4's torn-read false "premise WON", root-caused as the harness bug, fixed with the tolerant catcher reader, rt-11-4 14/14 `20261203T162907-10b26a71e-4174803` + rt-11-8 18/18 `20261203T163709-10b26a71e-133485` re-verified solo; the runbook commit `8053629d5` landed mid-run — docs only, no scenario code changed after the run started).** - [x] Cap matrix table PR'd into `docs/security.md` (cap × feature), each cell evidenced by a scenario run. (DONE 2026-12-03: the "Capabilities and container blast radius" section — the capability × feature matrix from rt-5-4, the four-shape blast-radius table from rt-5-3, and the minimum-cap recipe `--cap-drop=ALL` + NET_ADMIN/SYS_ADMIN/SYS_PTRACE/NET_RAW/SYS_RESOURCE with the drop conditions per soft cap) - [ ] **Phase 5 part 3, first half complete (the propagation + pressure rows)**: rt-5-6 **BLOCKED** (15/15, `20261203T231843-b48e19d1e-3186309` — **the rslave row holds and the e13287e7b regression guard is exact (gauges 0/WARN silent on the row, gauges 1/WARN fired on an rprivate twin), but the rprivate failure mode is two defects, not the documented one**: a named netns created after the daemon started is never collected (no records for its listener in the twin's catcher — the /proc-scan fallback is also blind: docker-default AppArmor denies ptrace-read of unconfined host peers regardless of CAP_SYS_PTRACE, dmesg-evidenced), AND the twin emits misattributed records — `ip netns add(8)` stages the entry as a mode-0000 file over which rprivate never propagates the nsfs mount, so the resolver's readdir+fstat admits the bare FILE, the daemon's open fails EACCES (the counter that fires is `openAndSetNSWithRetries{variable="open"}` — setns is never attempted), and `netNamespaceInstance` proceeds anyway: the diag socket opens in its own (host) netns and gets stored as that namespace's collector, so the HOST's socket inventory flows under the tenant's name (~8.5k records/run, netnsInode = the file's tmpfs inode) — silently, every poll — a product issue to file; `rslave` guidance + the detectors are in `docs/security.md` and the RUNBOOK), rt-5-7 **BLOCKED** (14/14, `20261204T003453-b48e19d1e-3641655` — **bounded at fleet scale**: at 10k host processes the discoverNamespaces p99 is 0.088s (baseline ~0.005s, bound 1.0s), no `reconcile_incomplete` fires, victim coverage lag stays 0s through the flood and after the drain, daemon CPU 121% (<250% bound) with RSS +27MB, and the skipped counter's growth is exactly one-per-pid-per-scan (+179,912 over 21 scans) — the docker-default ptrace-read line again, no retry storm. Two more pipefail-in-assignment silent-death lessons encoded (guard every grep pipeline feeding a `$()`, bound curls and docker stats with timeouts), and the twin's metrics/logs/mountinfo snapshot before asserting — the counters overturned the first mechanism theory. -- [ ] **Phase 5 part 3, second half complete (the RT-11 tier-3 rows)**: rt-11-9 **CONFIRMED** (11/11, `20261204T104157-ad321054a-3536908` — **the one-line full blind: the docker socket is uid-equivalent root** — a plain curl via the bind-mounted socket POSTs the daemon to `stop` (204), or `pkill -9` over --pid host; no daemon-side counter can exist (the daemon is dead — /metrics 000, the catcher freezes); the socket restarts it too — the attacker owns lifecycle in both directions; the plain tier has neither vector, which IS the invariant, and the external arrival check is the only detector), rt-11-10 **BLOCKED** (13/13, `20261205T020601-ad321054a-2280188` — **firewall tampering is only detectable via delivery health, and the counters DO page**: the deliver blind (OUTPUT DROP to :9999) freezes the catcher while the daemon stays healthy-while-dark; the envelope queue fills within ~30 s, queueFull + a `queue_depth` drop every poll after, Write/Dial on the 30 s deadline + 3×30 s dial cycle → the `attempts` drop (226 evictions over 480 s in the calibration run); rule-out → the queue drains, delivery recovers; the scrape blind (INPUT DROP to :9088) is absence-only by construction — no daemon-side counter can exist for its own exposition failing, the external watchdog is the detector, exactly as the RUNBOOK documents), rt-11-11 **CONFIRMED — #389 (S2)** (8/8, `20261205T023850-ad321054a-2612158` — **the netns flood KILLS the daemon**: the per-namespace collector inits (each holding a locked OS thread) pass the Go runtime's 2000-thread ceiling BEFORE the 4096 `-maxNetns` cap — `fatal error: thread exhaustion`, exit 2, the catcher freezes (the full-fleet blind); the admission bounds and the thread ceiling are mutually inconsistent — the cap sits ABOVE the budget; fix = cap under the thread budget, unlock after init, limit concurrent inits, or raise SetMaxThreads; the scenario's survives path is the regression guard), rt-11-12 **BLOCKED** (11/11, `20261205T032136-ad321054a-3074828` — **the entry-file poison is counted and pageable — and the #386 misattribution is the measured setns leg**: a drop+re-add poison (`ip netns del`, gap, `ln -s /dev/null`) makes the fresh collector's open succeed on the symlink and all 10 setns retries fail EINVAL (`Setns` +10, `SetnsAfterRetries` +1), then the caller PROCEEDS on fd -1 — host dumps under the tenant's name, 15 → 6679 records with the listener-port count frozen (the discriminator); the ro,rslave row daemon is untouched). rt-11-13 deferred after task 5.9 (it reuses the RT-6 rows). Harness lessons (all encoded, the big four): **matrix.sh leaves `RT_READ_TOKEN` EMPTY until `xtcp2_victim_read_token()` runs** — a scenario reading authed metrics without it reads a permanent 0 and can hang forever on a counter that never lights (rt-11-10 runs 1–3); **`|| echo 000` double-prints on one line** (curl -w's 000 has no trailing newline — `000000`, which tail -n1 cannot dedupe; the fix is `|| true` + exact equality); **every metric read through a possibly-DEAD daemon is a vacuous 0** — check liveness first, and a monotonic counter that appears to decrease is a dead-scrape proof (rt-11-11 run 1); **the /run/netns entry file IS the nsfs bind mount** — `rm -f` fails EBUSY (the drop must be `ip netns del`; pre-clean idempotently, or the next `ip netns add` collides). **Final regression: the 48-row matrix pending before the PR merges.** +- [x] **Phase 5 part 3, second half complete (the RT-11 tier-3 rows)**: rt-11-9 **CONFIRMED** (11/11, `20261204T104157-ad321054a-3536908` — **the one-line full blind: the docker socket is uid-equivalent root** — a plain curl via the bind-mounted socket POSTs the daemon to `stop` (204), or `pkill -9` over --pid host; no daemon-side counter can exist (the daemon is dead — /metrics 000, the catcher freezes); the socket restarts it too — the attacker owns lifecycle in both directions; the plain tier has neither vector, which IS the invariant, and the external arrival check is the only detector), rt-11-10 **BLOCKED** (13/13, `20261205T020601-ad321054a-2280188` — **firewall tampering is only detectable via delivery health, and the counters DO page**: the deliver blind (OUTPUT DROP to :9999) freezes the catcher while the daemon stays healthy-while-dark; the envelope queue fills within ~30 s, queueFull + a `queue_depth` drop every poll after, Write/Dial on the 30 s deadline + 3×30 s dial cycle → the `attempts` drop (226 evictions over 480 s in the calibration run); rule-out → the queue drains, delivery recovers; the scrape blind (INPUT DROP to :9088) is absence-only by construction — no daemon-side counter can exist for its own exposition failing, the external watchdog is the detector, exactly as the RUNBOOK documents), rt-11-11 **CONFIRMED — #389 (S2)** (8/8, `20261205T023850-ad321054a-2612158` — **the netns flood KILLS the daemon**: the per-namespace collector inits (each holding a locked OS thread) pass the Go runtime's 2000-thread ceiling BEFORE the 4096 `-maxNetns` cap — `fatal error: thread exhaustion`, exit 2, the catcher freezes (the full-fleet blind); the admission bounds and the thread ceiling are mutually inconsistent — the cap sits ABOVE the budget; fix = cap under the thread budget, unlock after init, limit concurrent inits, or raise SetMaxThreads; the scenario's survives path is the regression guard), rt-11-12 **BLOCKED** (11/11, `20261205T032136-ad321054a-3074828` — **the entry-file poison is counted and pageable — and the #386 misattribution is the measured setns leg**: a drop+re-add poison (`ip netns del`, gap, `ln -s /dev/null`) makes the fresh collector's open succeed on the symlink and all 10 setns retries fail EINVAL (`Setns` +10, `SetnsAfterRetries` +1), then the caller PROCEEDS on fd -1 — host dumps under the tenant's name, 15 → 6679 records with the listener-port count frozen (the discriminator); the ro,rslave row daemon is untouched). rt-11-13 deferred after task 5.9 (it reuses the RT-6 rows). Harness lessons (all encoded, the big four): **matrix.sh leaves `RT_READ_TOKEN` EMPTY until `xtcp2_victim_read_token()` runs** — a scenario reading authed metrics without it reads a permanent 0 and can hang forever on a counter that never lights (rt-11-10 runs 1–3); **`|| echo 000` double-prints on one line** (curl -w's 000 has no trailing newline — `000000`, which tail -n1 cannot dedupe; the fix is `|| true` + exact equality); **every metric read through a possibly-DEAD daemon is a vacuous 0** — check liveness first, and a monotonic counter that appears to decrease is a dead-scrape proof (rt-11-11 run 1); **the /run/netns entry file IS the nsfs bind mount** — `rm -f` fails EBUSY (the drop must be `ip netns del`; pre-clean idempotently, or the next `ip netns add` collides). **Final regression: green in one `redteam-matrix` run on `79375582b` — 48 rows, 0 failed** (the review-fix commit re-verified all three restructured scenarios solo first — rt-11-10 `20261205T044330-1a5a5db1e-3510733` 13/13, rt-11-11 `20261205T044835-1a5a5db1e-3660263` 8/8, rt-11-12 `20261205T045802-1a5a5db1e-3675844` 11/11 — then the full sweep confirmed the forks hold under matrix `XTCP2_EXPECT` control: rt-11-10 BLOCKED, rt-11-11 CONFIRMED, rt-11-12 BLOCKED, all PASS). - [x] rt-11-12 (netns entry poisoning) resolves BLOCKED (errors counted + gauge) or CONFIRMED (silent drop → S2 issue). (DONE 2026-12-05, 11/11 BLOCKED `20261205T032136-ad321054a-3074828`: the failure IS counted — `Setns` +10 and `SetnsAfterRetries` +1 at the re-add — and the measured shape is the #386 misattribution setns leg: host dumps under the tenant's name, 15 → 6679 records with the listener-port count frozen; the per-ns gauge gap stays #371) - [x] RUNBOOK.md complete for all 7 links × 4 tiers (28 cells), each naming a concrete metric/log/absence-alert. (DONE 2026-12-03, `8053629d5`: `vagrant/redteam/RUNBOOK.md` — every cell names its detector, evidence cited (V) for every cell as of 2026-12-05 — the last four (rt-11-9..12) landed their measured evidence when task 5.8's rows ran; rt-11-11's cell is V-CONFIRMED/#389, rt-11-12's open question is answered in the gaps section. First rule, alert rules 1–8, and the known gaps #337/#370/#371 up front; docs/security.md carries the companion section.) - [ ] Missing-gauge issues from Phase 4 all closed or scheduled with owners.