From d60b2000753246884af461da666505558d5c8b26 Mon Sep 17 00:00:00 2001 From: "randomizedcoder dave.seddon.ca@gmail.com" Date: Sun, 29 Nov 2026 21:17:24 -0800 Subject: [PATCH 1/6] =?UTF-8?q?feat(redteam):=20Phase=204=20part=204=20?= =?UTF-8?q?=E2=80=94=20the=20churn/cgroup=20suite=20(rt-4-6,=20rt-11-8,=20?= =?UTF-8?q?rt-4-8),=20task=204.11=20wrap-up?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three scenarios close Phase 4: - rt-4-6 namespace/socket churn storm (16/16, 20261130T041837-848ebbe00-1287288): 149 netns add+del cycles in 240 s (one launch/s, each container 2500 LISTEN + 2500 client sockets, dead ~2.5 s, --rm), poll_sockets 237->7875 mid-storm, CPU 111-114% of 4 vCPUs, victim records flowing MID-storm, reconcile_incomplete_total 0->0. Post-storm convergence waits (not fixed sleeps — measured: in-flight goroutines take ~2 min to drain): go_goroutines 51->51, process_open_fds 53->53, poll_sockets back to 245 (a leaked dead netns counts 1M unknown sockets in the gauge, so baseline-level = the map drained). No fd leak, no goroutine leak, no restart. The 24 h variant is env-gated (RT_CHURN_SECS=86400), never a matrix default. - rt-11-8 self-churn + reconcile amplification (18/18, 20261130T042718-848ebbe00-1464077): 20 docker restart cycles ~4.5 s apart, each re-packing 10000 sockfill loopback pairs (poll_sockets 241->20244): mid-storm victim coverage lag 0 s (the row's verdict criterion), reconcile complete p99 0.00032 s (the 1 s budget is 3000x above), add_rate=0, no leak, no restart. - rt-4-8 poll amplification under a cpu quota (16/16, 20261130T045657-848ebbe00-1525702): the refocused cgroup-cap variant (XTCP2_CPUS=2, the deploy axis): an admin sets the 1 s floor and runs TriggerPollBurst 120x1s — record rate 116->491 rec/s (4.2x, the full-dump-per-poll cost) while daemon CPU stays 130.9%/132.0% vs the 210% quota bound, RSS 24453->27002 kB, no OOM-kill, metrics answers through the burst, rate settles post-burst. The nuance: the burst multiplies RECORDS not CPU at this population; the record-volume residual is #342's family. Prod guidance: pin XTCP2_CPUS — the default deploy is unlimited. - task 4.11 observability wrap-up: of the four gauges the suite needs, three already exist and are now asserted in-scenario (process_open_fds, go_goroutines, Poller/pollToDoneDuration + PollTimeout, the delivery-error counters); per-namespace coverage lag does not exist (aggregate-only) — filed #371. NEW measured gap filed as #370: netns add/del is invisible in metrics — the per-poll reconcile (the ACTUAL discovery path, reconcileBeforePoll) returns its add/del deltas uncounted (poller.go reconcileThenPoll logs at debug>10 and drops them), and mapReconciler's stores/dels only fire on the 6 h background ticker, which never ticks in a 4-min run. Findings rows, plan VERIFIED cells, and the implementation DoD updated. Gates: redteam-lint 0 findings, lint-baseline exit 0. --- docs/redteam-implementation.md | 6 +- docs/redteam-plan.md | 6 +- nix/redteam.nix | 3 + vagrant/redteam/findings.md | 3 + vagrant/scenarios/rt-11-8-self-churn.sh | 287 +++++++++++++++++ vagrant/scenarios/rt-4-6-namespace-churn.sh | 302 ++++++++++++++++++ .../rt-4-8-poll-amplification-cpu-quota.sh | 216 +++++++++++++ 7 files changed, 818 insertions(+), 5 deletions(-) create mode 100644 vagrant/scenarios/rt-11-8-self-churn.sh create mode 100644 vagrant/scenarios/rt-4-6-namespace-churn.sh create mode 100644 vagrant/scenarios/rt-4-8-poll-amplification-cpu-quota.sh diff --git a/docs/redteam-implementation.md b/docs/redteam-implementation.md index f55de2619..1b218c269 100644 --- a/docs/redteam-implementation.md +++ b/docs/redteam-implementation.md @@ -268,10 +268,12 @@ completing the RT-4 suite and RT-11 tiers 1–2. - [x] Phase 4 part 2 complete (the stream/gRPC suite): rt-4-3 **BLOCKED** (11/11 — read-cred oversize answered PermissionDenied at the method ACL before the 4 MB cap is even reachable; admin-cred oversize answered ResourceExhausted; a 10×20 reading storm cost a linear 299 goroutines, 1.1 M records, no leak 71→299→71), rt-11-3 **CONFIRMED** (11/11 — **the strongest RT-11 crossover**: ONE never-reading authenticated stream took the catcher 1993 → 0 lines/6 s; `flatRecordServiceSend`'s blocking per-client Send runs per record on the decode hot path, so one stalled stream backpressures the whole fleet; API stayed 200 — the tier-2 split; recovery ≤6 s, no leak), rt-4-4 **BLOCKED** (11/11 — RSS slope −17 KiB/s under 4 paced readers, and the backpressure finding: the catcher collapsed 1494 → 0 lines/6 s with EXACTLY 32 records in 240 s — the paced wedge, same root cause as rt-11-3), rt-2-9 **CONFIRMED** (7/7 — stream-expiry carry-over: 2158/2200 records flowed ~50 s past the skew-0 window; file-don't-fix, ops note: key rotation does not break held-open streams). New tool: grpcstorm (storm/oversize/wedge/paced/HMAC shapes, static, in the attacker tools tar); new deploy axis `XTCP2_PPROF` (a loopback, token-gated debug listener for goroutine-count asserts — an observability axis, not a surface change); rt-2-2's Phase-4 deferral landed as row rt-2-9. Full matrix regression: **30 scenarios, 29 PASS + 1 harness race fixed + re-verified solo** — rt-2-2's in-minute replay minted at :44 and the tcpdump window pushed the replay past the boundary (correct 401 under skew 0; the assert raced, not the product): the guard now lands the mint at 05..18 and re-mints once if a slow provision still crosses. - [x] Phase 4 part 3 complete (the delivery-outage suite): rt-4-7 **BLOCKED** (15/15, the split verdict — the s3 queue sink: RSS slope 70 KiB/s, the outage counted (`destS3Parquet/upload/error`, `s3_dropped_total=8`), recovery on endpoint return (objects 1270→2375); the tcp half: the permanent blind measured — counters light immediately, polling continues, the catcher restart changes nothing, only a daemon restart re-dials), rt-11-4 **BLOCKED** (14/14 — 300,008 thief sockets, victim coverage lag 0 s (parallel per-netns dumps + the 1 s poll-timeout valve), PollTimeout firing every cycle, RSS 29→31 MiB, and the amplifier at scale: 211,244 lines/6 s ≈ 100× baseline; the walkable budget engaged `xtcp_poll_degraded_total{level="sample"}` with victims still at 0 s lag), rt-11-5 **CONFIRMED** (16/16 — the L2 freeze: a CAP_NET_RAW sibling ARP-blackholes the sink via a 200 ms gratuitous-reply loop; the poller FREEZES in the blocked Write (no deadline, sync on the poll goroutine) for the whole retransmit window (~15.4 min at the prod default) with zero error counters and scrape 200; de-poison mid-window = full catch-up with no loss; the window closed = counters light + delivery permanently dead). New tool: arppoison (static, in the attacker tools tar); new deploy axes `XTCP2_MAX_RECORDS` (rt-11-4's walkable budget) and `XTCP2_SINK_IP` (rt-11-5's dedicated sink alias — poisoning the gateway takes the docker-proxy replies down with it, measured); the freeze finding filed as #345. Full matrix regression: **33 scenarios, 32 PASS + 1 tool race fixed + re-verified solo** — rt-4-3's oversize probe (leg B) raced the transport's arrival-based recv-limit kill against a fanned-out record beating the 8 MB frame on a fresh slow-start conn (measured OK 3/3 in the matrix, ResourceExhausted 12/12 by hand): the probe now drains Recv to the terminal verdict. - [x] **Product fixes #345 + #339 landed with the expectation flips in the same change** (the S2 pair the delivery-outage suite surfaced): the tcp destination is now a bounded queue + worker — `Send` never blocks (the poller can never freeze on the sink), every write AND dial carries `tcp_write_timeout` (config field 120, validate-gted/lte'd to [1s, 1h], Go belt `resolveTCPWriteTimeout`, default 30 s, CLI `-tcpWriteTimeout`/`TCP_WRITE_TIMEOUT` env), the queue is `envelopeQueue` shared with s3 (moved untagged to destinations_queue.go — tcp is in every flavor including stdlib-only), and a failed write reconnects under full-jitter backoff (the `backoffWindow` cap derived like s3's: clamp(poll_frequency/10, 1s, 1h)) with 3 attempts per envelope, then drop-and-count. New counters: `xtcp_tcp_dropped_total{reason}` / `_bytes_total` / `xtcp_tcp_buffered_bytes{stage}` + `destTCP` Dial/Reconnect/queueFull/dropped. Verified by the same attacks that pinned the bugs: **rt-11-5 MITIGATED 18/18** (polls keep issuing through the stall 25→47/32 s — the freeze gone; Write/error=9, Dial/error=8, drops=3 while dark; de-poison heals with NO restart, reconnects=1; second cycle repeats — a REACHABLE neighbor entry ignores gratuitous ARP until STALE ~30 s, the flip is now a bounded wait) and **rt-4-7 BLOCKED 15/15** (the catcher restart heals delivery, reconnects=1, 2482 lines/6 s — no daemon restart). Harness: deploy axis `XTCP2_TCP_WRITE_TIMEOUT` (Vagrantfile arg 12). Harness lesson: `promLabels` order is function, VARIABLE, type — `WithLabelValues("destTCP","Write","error")` emits `type="error",variable="Write"`; grep the emitted order or the assert reads empty. Post-merge regression: **33/33 on main `14d7e1c38c` (PR #352)** — the first full-matrix sweep hit an environmental cascade (unattended-upgrades grabbed the dpkg frontend lock at scenario 24 — the last five scenarios failed provisioning in a row; `common.sh` now stops/masks the apt-daily timers and waits out an in-flight run, re-verified across all 33 provisions), and rt-11-5's dark window needed the two-shape accept: the write deadline can let a re-dial's broadcast ARP beat the poison — delivery SELF-HEALS mid-attack (1262 lines/6 s, drops=0, evidence `20261127T065504-195d45c15-839055`) — a stronger mitigation than the sustained stall the assert had pinned as the only valid shape (re-verified 18/18 MITIGATED shape-A, `20261127T071651-195d45c15-986471`). -- [ ] 24 h churn variant runs clean overnight once (logged evidence), or its blocker filed. (Phase 4 part 4) +- [ ] 24 h churn variant runs clean overnight once (logged evidence), or its blocker filed. (Phase 4 part 4 — the variant is built and env-gated: `RT_CHURN_SECS=86400 nix run .#redteam-rt-4-6`; all asserts duration-agnostic; the overnight run itself is outstanding) - [x] rt-11-5 shows delivery metrics lighting up during the L2 kill (assert specific series non-zero), or files the observability gap. (landed with the #345/#339 fix: the scenario asserts `destTCP` Write/Dial errors ≥1 while dark and — shape A — `xtcp_tcp_dropped_total` ≥1; the silent window is now counted, verified both cycles) - [x] Phase 4 part 4 (conntrack leg): rt-11-6 **BLOCKED** (17/17, shape A `20261128T031048-c0f904e3d-3955865`; shape B 16/16 `20261127T232913-b7769a466-1209893`): the spray cannot stop reporting — established delivery immune, the re-dial races the slot leak and the #352 queue bounds the loss (both shapes green), no restart, polls never stop. The measured crossover is the ops view: a fresh scrape via docker-proxy needs a conntrack entry, so /metrics goes 000 while records flow — "absence of metrics must itself alert" confirmed end-to-end; harness lessons (mgmt-/24 NOTRACK, pgrep self-match, session-hold hang) encoded in-scenario. -- [x] rt-11-7 **survives** (18/18, `20261129T091855-df22997b2-1827895`): a NET_ADMIN co-tenant builds pathological-but-legal own-netns state on the new locality deploy axis (`XTCP2_ENRICH=locality` — a rtnetlink listener inside every discovered netns); 87 links / 976 corpus neighbors / 1012 routes at the kernel's own extremes (15-char names, 255-char labels, metric 0/4294967295, 32-nexthop multipath, v6 zero-MAC), the listener parsed **+1141 corpus events live** and a forced ROUTE event re-dumped the full corpus (snapshot periodic 1→2) — no panic, no restart, scrape 200, catcher grew through the build. No fixture needed. Measured coverage finding: localityGroups excludes GroupNeigh — the deployed daemon never reads neighbor tables; the plan's "huge neighbor tables" leg was NOT exercised — the pathological-MAC corpus is kernel-resident only (a fixture seed for the day the enricher reads neighbors). Harness: dpkg-lock-era VM disk full (catcher 5.8 G + docker json logs 8.1 G) fixed at the source — common.sh truncates both at provisioning. +- [x] rt-11-7 **survives** (18/18, `20261129T091855-df22997b2-1827895`): a NET_ADMIN co-tenant builds pathological-but-legal own-netns state on the new locality deploy axis (`XTCP2_ENRICH=locality` — a rtnetlink listener inside every discovered netns); 87 links / 976 corpus neighbors / 1012 routes at the kernel's own extremes (15-char names, 255-char labels, metric 0/4294967295, 32-nexthop multipath, v6 zero-MAC), the listener parsed **+1141 corpus events live** and a forced ROUTE event re-dumped the full corpus (snapshot periodic 1→2) — no panic, no restart, scrape 200, catcher grew through the build. No fixture needed. Measured coverage finding: localityGroups excludes GroupNeigh — the deployed daemon never reads neighbor tables; the plan's "huge neighbor tables" leg was NOT exercised — the pathological-MAC corpus is kernel-resident only (a fixture seed for the day the enricher reads neighbors). Harness: dpkg-lock-era VM disk full (catcher 5.8 G + docker json logs 8.1 G) fixed at the source — common.sh truncates both at provisioning; xtcp2_deploy truncates BEFORE the tarball scp (a full disk killed the delivery itself); tcp-stress NUL-byte stdout capped (`--log-opt max-size`) — the work containers had filled 4.0 G each. +- [x] **Phase 4 part 4 complete (the churn/cgroup suite)**: rt-4-6 **BLOCKED** (16/16, `20261130T041837-848ebbe00-1287288` — 149 netns add+del cycles in 240 s, poll_sockets 237→7875, CPU 111–114% of 4 vCPUs, victim flowing MID-storm, `reconcile_incomplete` 0→0; post-storm convergence go_goroutines 51→51 / FDs 53→53 / poll_sockets 245 — no leak, no map leak; **finding #370: netns add/del is invisible in metrics**, the per-poll reconcile drops its deltas, mapReconciler's stores/dels only fire on the 6 h ticker), rt-11-8 **BLOCKED** (18/18, `20261130T042718-848ebbe00-1464077` — 20 `docker restart` cycles each re-packing 10000 sockfill pairs (poll_sockets 241→20244): mid-storm victim lag 0 s, reconcile p99 0.00032 s, `add_rate`=0, no leak — self-churn does not even register), rt-4-8 **BLOCKED** (16/16, `20261130T045657-848ebbe00-1525702` — the refocused cgroup-cap variant, XTCP2_CPUS=2: an admin TriggerPollBurst 120×1 s multiplies records 116→491 rec/s while CPU stays 130.9%/132.0% vs the 210% quota bound, RSS 24453→27002 kB, no OOM, metrics answers, rate settles post-burst; the nuance: the burst multiplies RECORDS not CPU — the record-volume residual is #342's family; prod guidance: pin XTCP2_CPUS). The 24 h churn variant is env-gated (`RT_CHURN_SECS=86400 nix run .#redteam-rt-4-6`, never a matrix default) — all asserts duration-agnostic. +- [x] **Task 4.11 wrap-up (the observability enabler)**: of the four gauges the suite needs, three already exist and are now asserted in-scenario — FD usage (`process_open_fds`, the standard collector), goroutines (`go_goroutines`), poll-cycle duration (`Poller/pollToDoneDuration` + `PollTimeout`), delivery errors (`destTCP/Write/error`, `destS3Parquet/upload/error`, `Poller/envelopeFlush/error`); per-namespace coverage lag does NOT exist (aggregate-only) — filed as **#371**; the NEW measured gap — netns churn invisibility — filed as **#370** (the per-poll reconcile's add/del deltas are dropped). - [ ] Every scenario traps cleanup; a final "victim still reporting" assertion runs after each attack (the RT-11 invariant). - [ ] The wire-the-limits issue (max_connections/accept-rate) has measured evidence attached. diff --git a/docs/redteam-plan.md b/docs/redteam-plan.md index d656a187c..ee7a70012 100644 --- a/docs/redteam-plan.md +++ b/docs/redteam-plan.md @@ -181,9 +181,9 @@ left auth disabled. These test what admin access is worth. | rt-4-3 | gRPC stream abuse | h2load/ghz: many conns × 20 streams, 4 MB messages, reflection flood | per-conn stream cap 20, 4 MB message limit; no global quota | **VERIFIED 2026-11-25 (BLOCKED — all three legs land inside the guards)**: read-cred oversized `PollFlatRecords` → PermissionDenied ×3 (the method ACL answers BEFORE the recv cap — `PollFlatRecords` is admin-served, so a read credential never reaches the size check and cannot even enumerate the method); admin-cred oversized → ResourceExhausted ×3 (MaxRecvMsgSize=4MB answers); the reading storm (10 conns × 20 streams × 100 rec/s, 60 s) → goroutines 71→299 (linear, ~1/stream + ~5/conn), scrape 200, catcher flowing, 1.1 M records delivered, no leak after (71→299→71). Unauthenticated reflection is the rt-1-2 shape (same StreamServerInterceptor) | bounded degradation only; assert no goroutine leak after close (metrics//`/debug` after test — or pprof via loopback) | S3 | | rt-4-4 | Slow FlatRecords consumer | open authenticated stream, read 1 msg/30 s, never cancel | gRPC flow control should backpressure the daemon pipeline | **VERIFIED 2026-11-25 (BLOCKED on the OOM axis — and the backpressure is the finding)**: 4 paced readers (1 msg/30 s) for 240 s — RSS slope −17 KiB/s (29 MiB flat; envelope row/byte caps + record pool hold), daemon alive. But sink delivery COLLAPSED to the readers' pace: catcher 1494 → **0 lines/6 s** while held, and exactly 32 records crossed in 240 s — the 4 × 8 paced reads, no more. `flatRecordServiceSend`'s blocking per-client Send runs on the record hot path, so the whole pipeline (envelope flush included) is coupled to the slowest reader: the rt-11-3 wedge, paced. 1 h soak via `RT_SOAK=1h` (env-gated, not in the matrix) | daemon memory bounded under stalled consumers for 1 h; no OOM; record the envelope-buffer high-water mark | S3 | | rt-4-5 | Scrape storm | 100 parallel scrapes of `/metrics`, `/metrics-all`, detail paths | 10 in-flight cap on main path; category caps 4; 10 s handler timeouts | **VERIFIED 2026-11-25 (BLOCKED)**: the fast path self-throttles (100x 200, p99 11 ms — the ~17 ms body answers faster than staggered curls stack 10-deep) and the cap engages where a pileup could form: `/metrics-all` 10x 503, `/metrics/link` 3x 503, zero failed conns, no pileup (clean scrape 1.9 ms after), healthz 200, catcher flowing throughout | 503/queue behavior matches docs; no pileup; p99 latency recorded | S4 | -| rt-4-6 | Namespace/socket churn storm | run `nsTest` + a script creating/destroying netns and 10k sockets rapidly in co-tenant containers visible to the daemon | reconcile before each poll; retry loops for vanished veths | no fd leak, no goroutine leak, bounded CPU, daemon survives 24 h churn (ties into TODO-SOON AI098) | S2 | +| rt-4-6 | Namespace/socket churn storm | run `nsTest` + a script creating/destroying netns and 10k sockets rapidly in co-tenant containers visible to the daemon | reconcile before each poll; retry loops for vanished veths | **VERIFIED 2026-11-30 (BLOCKED — the storm loses on every axis)**: 149 netns add+del cycles in 240 s (one launch/s, each container 2500 LISTEN + 2500 client sockets, dead ~2.5 s, `--rm`): poll_sockets 237→7875 mid-storm, CPU 111–114% of 4 vCPUs, victim records flowing MID-storm, `reconcile_incomplete_total` 0→0; post-storm convergence **go_goroutines 51→51, process_open_fds 53→53, poll_sockets 245** (a leaked dead netns would count 1M unknown sockets in the gauge) — no fd leak, no goroutine leak, no restart, 16/16 (`20261130T041837-848ebbe00-1287288`). **Finding #370: netns add/del is invisible in metrics — mapReconciler stores/dels only fire on the 6 h ticker; the per-poll reconcile (the ACTUAL discovery path) returns its deltas uncounted.** The 24 h variant is env-gated (`RT_CHURN_SECS=86400`), never a matrix default | no fd leak, no goroutine leak, bounded CPU, daemon survives 24 h churn (ties into TODO-SOON AI098) | S2 | | rt-4-7 | Broker-outage buffering | kill the in-VM Redpanda; watch daemon | franz-go backoff with jitter (design doc) | **VERIFIED 2026-11-26 (BLOCKED on the queue sink — split verdict, both halves measured)**: half 2 (s3parquet→Garage, the queue-shaped sink): daemon memory bounded while the sink is down (RSS slope 70 KiB/s; queue depth 16 / 64 MiB, oldest-first eviction), the outage is VISIBLE and COUNTED (`destS3Parquet/upload/error=1` after the backoff, `s3_dropped_total=8`), and minio dials per request so the daemon RECOVERS on endpoint return (objects 1270 → 2375) — the plan's expectation holds. Half 1 (tcp, the catcher): the Write errors immediately on the dead conn (FIN/RST — no stall), the counters light up, polling continues — but the blind is **PERMANENT**: a catcher restart changes nothing (0 lines/6 s with the catcher back; tcpDest never reconnects, #339), only a daemon restart re-dials (measured). The permanent-blind finding is asserted in-row and filed under #339. **FIXED same day (#339 landed with this expectation flip)**: the tcp destination is now a bounded queue + worker — Send never blocks, every write and dial carries `tcp_write_timeout`, a failed write reconnects under full-jitter backoff. Re-verified **BLOCKED 15/15** (evidence `20261126T110001-209ab068a-1548426`): the outage is counted (`destTCP` Write/error=24, Dial/error=25, `xtcp_tcp_dropped_total=9`), polls continue, and **the catcher restart heals delivery with NO daemon restart** (reconnects=1, 2482 lines/6 s after return) — the plan's expectation now holds on BOTH halves | memory bounded while dest is down; recovers on broker return; no unbounded queue | S3 | -| rt-4-8 | Admin-triggered poll amplification | (needs admin) poll burst against a host with 100 containers × 250 sockets | full-dump per poll | latency/CPU bounded; assert cgroup protection works | S3 | +| rt-4-8 | Admin-triggered poll amplification | (needs admin) poll burst against a host with 100 containers × 250 sockets | full-dump per poll | **VERIFIED 2026-11-30 (BLOCKED — the quota holds the line)**: the refocused cgroup-cap variant (the XTCP2_CPUS deploy axis, pinned 2; the 100-container population was premortem-refocused as arithmetic — rt-3-3 measured the mechanism). The admin sets the 1 s floor and runs TriggerPollBurst 120×1 s under the quota: record rate 116→491 rec/s (**4.2×**), daemon CPU **130.9%/132.0%** vs 116% baseline — inside the quota bound, RSS 24453→27002 kB, no OOM-kill, metrics answers through the burst, rate settles post-burst, no restart, 16/16 (`20261130T045657-848ebbe00-1525702`). The nuance: at this population the burst multiplies RECORDS not CPU (116→131% for 4.2× records — polling is cheap); the record-volume residual is #342's family (the burst's `-count` bounds it). Prod guidance: pin XTCP2_CPUS — the default deploy is unlimited | latency/CPU bounded; assert cgroup protection works | S3 | ### RT-5 Host attacks through xtcp2 (netlink and capabilities) @@ -278,7 +278,7 @@ listeners; true with `--network host` or published ports): | rt-11-5 | L2 kill of the delivery path | if the destination (Kafka/Redpanda, S3 endpoint container) is a sibling on the same bridge, both endpoints are on-path to each other: spoofed RSTs or ARP blackholing of the daemon→broker TCP. franz-go retries with jitter forever, so the daemon looks healthy while delivering nothing | jittered backoff (fleet design); reconnect | **VERIFIED 2026-11-26 (CONFIRMED — stronger than the premise: an L2 stall does not just blind delivery, it freezes COLLECTION)**: a privileged co-tenant (CAP_NET_RAW, sibling on the bridge — a dedicated docker0 alias keeps the gateway path clean so the API stays 200) ARP-blackholed the sink with a 200 ms gratuitous-reply loop (arppoison; existing entries flip with default arp_accept). Measured timeline: delivery dies instantly (0 lines/6 s); the Writes keep SUCCEEDING locally while SO_SNDBUF absorbs envelopes; the buffer fills → the Write blocks → **the whole poller freezes** (polls frozen 14 s at tcp_retries2=8; ~15.4 min at the prod default retries2=15) with **zero error counters** and scrape 200 — fully silent. De-poison mid-window: the buffered envelopes drain, the catcher catches up (1667 lines/6 s), no error counters, **no loss** — the blind is latency, not loss. The window closed (retries2=3): counters light up only then (the row's visibility premise holds, after the gap), polls resume, and delivery is permanently dead until a daemon restart (no reconnect, #339). **Product finding filed (#345)**: SetWriteDeadline + decouple the flush from the poll goroutine. **FIXED same day (#345 + #339 landed with this expectation flip)**: the tcp destination queues to a bounded worker (`Send` never blocks the poller), every write and dial carries `tcp_write_timeout` (default 30 s, deploy axis `XTCP2_TCP_WRITE_TIMEOUT`; this run pins 5 s), and a failed write reconnects under full-jitter backoff. Re-verified **MITIGATED 18/18** (evidence `20261126T111738-209ab068a-1688938`, two full poison cycles): polls keep issuing through the stall (25→47 over 32 s — the freeze is gone), the blind is VISIBLE and COUNTED while dark (Write/error=9, Dial/error=8, `xtcp_tcp_dropped_total=3`, scrape 200), de-poison heals delivery with NO daemon restart (reconnects=1, 2498 lines/6 s), and the second cycle repeats the whole arc (Write/error 10→14, polls 77→82, heals again at 2500 lines/6 s). The residual — delivery still stalls while the route is blackholed — is physics, bounded by the deadline and visible in the counters | assert delivery-failure counters/metrics make the blind *visible* (`xtcp_counts` delivery errors, `xtcp_gauges` delivery health); finding: sustained L2 kill = silent-ish outage without an external watchdog | S2 (fixed) | | rt-11-6 | Host noisy-neighbor starvation | CPU fork bomb without cpu quota, memory pressure toward OOM (xtcp2 has real RSS), **conntrack-table exhaustion** (mass short-lived flows through host NAT → `nf_conntrack: table full` drops the daemon's outbound SYN to Kafka/S3), pid-limit exhaustion breaking the `/proc` walk | container cgroup limits are deployment policy | **VERIFIED 2026-11-28 (BLOCKED — the spray loses; the ops view doesn't)**: the conntrack leg, measured twice (shape B `20261127T232913-…` 16/16; shape A `20261128T031048-…` 17/17). A plain-tier co-tenant spraying ~700 conns/s through docker0 (sockfill -spray: dial, close cleanly — each conn lingers ~120 s as a TIME_WAIT conntrack entry) pins the host netns table in ~20 s against the harness pin of 12288 (stock 262144 needs >2200/s sustained — a fleet, not a myth); dmesg ×1275. Established delivery is immune (49559 lines/6 s with the table full). A forced re-dial against the full table is a race: shape B healed THROUGH the storm (the spray's own TIME_WAIT expiry frees ~max/120 slots/s — 58027 lines/6 s, one counted Dial error); shape A went dark until the drain and the #352 queue bounded it (Dial/error=1, dropped=27, reconnects=1, no restart, polls +64 throughout). The row's real finding: **a fresh scrape through docker-proxy needs a new conntrack entry for the proxy's backend leg, so /metrics times out (000) while records keep flowing** — the monitoring path is the casualty, not collection; heals with the table. "Absence of metrics must itself alert" confirmed end-to-end: during the storm the fleet's own scrape IS the absent metric. | assert per-link effects and that each has a metric the fleet can alert on; finding: "absence of metrics must itself alert" — an external liveness watchdog is a deployment requirement | S2 (finding: the scrape-path blind) | | rt-11-7 | Own-netns parser crash attempt | pathological own netns (max-length ifnames, huge neighbor/route tables, nested veth/macvlan) hoping for a typed-parser panic; a panic in the poll path takes the whole daemon (the link-monitor panic-isolation issue is documented as open) | fixture-tested parsers, fuzz targets | **VERIFIED 2026-11-29 (BLOCKED — the corpus loses; the daemon does not flinch)**: a NET_ADMIN co-tenant builds pathological-but-legal own-netns state — 87 links (15-char IFNAMSIZ-1 names, 255-char ifalias labels, macvlan, vlan 4094, veth-under-bridge), 976 corpus neighbors (all five pathological MAC shapes; `ip neigh` prints 977 with the container's own gateway line), 1012 routes (metrics 0 and 4294967295, a 32-nexthop multipath, v6 zero-MAC fe80::1), fib rules at pref 4294967294/4294967295 — on the new locality deploy axis (`-enrichLocality -localityEvents`), so a rtnetlink listener runs INSIDE the attacker's netns. The attacker cannot send bytes: the kernel serializes the state into well-formed netlink and every message flows through the parsers. Measured: the listener parsed **+1141 corpus events live** through the build (events 108→1249); one forced ROUTE event after the 60 s quiet window fired a full re-dump (snapshot periodic 1→2 — the whole corpus re-parsed through the dump path); through all of it no panic, no restart, scrape 200, catcher grew through the build — a parser panic anywhere takes the daemon (no recover() in the listener path), none tripped. **Measured coverage gap (finding, not a crash): localityGroups excludes GroupNeigh — the deployed daemon never dumps or subscribes to neighbors; the plan's "huge neighbor tables" leg was NOT exercised — the pathological-MAC neighbor corpus is kernel-resident only, a fixture seed for the day the enricher reads neighbors** | daemon survives; any crash = S1-class finding feeding the fixture corpus | -| rt-11-8 | Self-churn + reconcile amplification | rapid own socket churn and `docker restart` loops make discovery/dockermeta/reconcile (which runs before each poll) burn the cycle; AI098 warn-storm | churn handling, retry logic | bounded reconcile cost; no coverage lag on victim namespaces | +| rt-11-8 | Self-churn + reconcile amplification | rapid own socket churn and `docker restart` loops make discovery/dockermeta/reconcile (which runs before each poll) burn the cycle; AI098 warn-storm | churn handling, retry logic | **VERIFIED 2026-11-30 (BLOCKED — self-churn does not even register)**: 20 `docker restart -t 0 rt-attacker` cycles ~4.5 s apart, each re-packing 10000 sockfill loopback pairs (poll_sockets 241→20244): mid-storm victim coverage lag **0 s** (the row's verdict criterion), reconcile `complete` p99 **0.00032 s** (the 1 s budget is 3000× above), victim records flowing mid-storm, post-storm go_goroutines 51→51 / FDs 53→53 / poll_sockets 250 (map drained), `add_rate`=0, `reconcile_incomplete`=0, no restart, 18/18 (`20261130T042718-848ebbe00-1464077`). The rt-4-6 observability finding (#370) applies verbatim: stores/dels stay 0 in this shape | bounded reconcile cost; no coverage lag on victim namespaces | **Tier 2 — co-tenant holding only a read credential:** rt-11-1/2/3 still apply unchanged (FDs and stream slots are consumed before authorization, and diff --git a/nix/redteam.nix b/nix/redteam.nix index 1653c3e4c..8611a73ff 100644 --- a/nix/redteam.nix +++ b/nix/redteam.nix @@ -247,6 +247,9 @@ in redteam-rt-11-5 redteam-rt-11-6 redteam-rt-11-7 + redteam-rt-4-6 + redteam-rt-4-8 + redteam-rt-11-8 ) failed=0 for s in "''${scenarios[@]}"; do diff --git a/vagrant/redteam/findings.md b/vagrant/redteam/findings.md index df8e6e43c..a041ed160 100644 --- a/vagrant/redteam/findings.md +++ b/vagrant/redteam/findings.md @@ -69,6 +69,9 @@ that gets fixed flips its `EXPECT` in the same PR as the fix | rt-11-6 | 2026-11-28 | bridge+raw+plain, SINK_IP=172.17.99.2 (conntrack leg) | BLOCKED | S2 (finding: the scrape-path blind) | `20261128T031048-c0f904e3d-3955865` (shape A), `20261127T232913-b7769a466-1209893` (shape B) | **The conntrack spray cannot stop xtcp2 reporting — but it CAN blind the ops view.** A plain-tier co-tenant (no caps; sockfill -spray, ~700 conns/s — dial, close cleanly, each conn lingers ~120 s as a TIME_WAIT conntrack entry; the harness pins nf_conntrack_max=12288 as time compression — stock 262144 needs >2200/s sustained, i.e. a noisy-neighbor fleet) pins the HOST netns table in ~20 s; dmesg logs `nf_conntrack: table full` ×1275. Measured effects: (1) **established delivery is immune** — 49559 lines/6 s with the table full (its entry is already allocated); (2) a re-dial against the full table is a RACE the daemon usually wins (the storm's own TIME_WAIT expiry frees ~max/120 slots/s): shape B healed THROUGH the storm (58027 lines/6 s mid-storm, one counted Dial error); shape A went dark until the drain and the #352 queue bounded it (Dial/error=1, dropped=27, reconnects=1, delivery healed with NO restart, polls +64 throughout). The two-shape assert accepts both; the only failure is a silent stall. (3) **The real blind: a fresh scrape through docker-proxy needs a new conntrack entry for the proxy's backend leg, so /metrics times out (000) while records keep flowing** — the daemon is fine, the monitoring path is the casualty; heals with the table (401). "Absence of metrics must itself alert" confirmed end-to-end: during the storm the fleet's scrape IS the absent metric. Harness lessons (encoded in-scenario): the vagrant control path is the DHCP mgmt net **192.168.121.0/24, NOT the private /24** — NOTRACK mgmt+private+lo or the storm stalls the scenario's own ssh on SYN retransmits and starves the next provisioning's DNS-over-ens6; a mid-run death MUST reset the pin (defensive ct_reset + EXIT trap) or every following scenario starves; `pgrep -f` matches its own cmdline (listener never started — spray ok=0 for 85 K attempts) and `A || B &` hangs the ssh session (the subshell holds stdout waiting on socat) — check with ss, start bare. | | rt-11-7 | 2026-11-29 | bridge+raw+plain, ENRICH=locality (the -enrichLocality -localityEvents axis) | BLOCKED | none | `20261129T091855-df22997b2-1827895` (18/18) | **The parser corpus loses; the daemon does not even flinch.** A NET_ADMIN co-tenant builds pathological-but-legal own-netns state (all probe-verified kernel-accepted): 87 links (veth pairs with 15-char IFNAMSIZ-1 names, 255-char ifalias labels, macvlan + vlan id 4094 on a veth, a veth enslaved to a bridge), 976 corpus neighbors (39 veths × 25 cycling all five pathological MAC shapes — zero, broadcast, IPv4-mcast 01:00:5e:ff:ff:ff, IPv6-mcast 33:33:…, locally-administered 02:00:… — plus the v6 zero-MAC fe80::1; `ip neigh` prints 977 lines, the +1 being the container's own eth0 gateway), 1012 routes (metrics 0 and 4294967295 — the u32 extremes, a 32-nexthop multipath route, v6 zero-MAC fe80::1 + metric-max /128), fib rules at pref 4294967294/4294967295. The attacker cannot send bytes: the kernel serializes the state into well-formed netlink and the daemon parses it via the per-netns locality listener (deployed on the new locality axis; a fresh container's listener starts within 5 s, probe-verified). Measured: **the listener parsed +1141 corpus events live through the build** (localityListener events 108→1249), a forced ROUTE event after the 60 s quiet window fired a full re-dump (snapshot periodic 1→2 — the whole corpus re-parsed through the dump path), and through all of it: no panic, no restart, scrape 200, the catcher grew through the build (8503→8984 lines/6 s). A parser panic anywhere takes the whole daemon (no recover() in the listener path) — none tripped. **Measured coverage gap (finding, not a crash): localityGroups (pkg/xtcp/enrich_locality_listen.go) excludes GroupNeigh — "Neighbors are not one" — so the deployed daemon never dumps or subscribes to neighbor tables at all; the plan's "huge neighbor tables" leg was NOT exercised — the 976 pathological-MAC neighbors are kernel-resident only** (they seed a fixture corpus for the day the enricher starts reading neighbors). Harness lessons (encoded): 16-char ifnames are kernel-rejected ("Attribute failed policy validation" — IFNAMSIZ enforced); routes on DOWN veths are rejected ("Device for nexthop is not up" — bring links up first); a neigh-replace forced event is INVISIBLE to the listener (probe: events flat at a neigh event, +1 periodic/rebuilds at a route one — force ROUTE events); POSIX sh (dash) rejects `${n/a/b}` — derive peer names with printf; `wait_for` returns 1 on timeout and set -e kills the scenario before its RESULT line — guard with `|| true`; the emitted label order is function,TYPE,variable (read the raw series, and fold absent series to 0). | +| rt-4-6 | 2026-11-30 | bridge+raw+plain, host-side churn driver (stated vantage: the fleet-operator position — a PLAIN attacker cannot create netns; NET_ADMIN does not grant it either, the rt-11-7 ladder) | BLOCKED | S4 (observability, #370) | `20261130T041837-848ebbe00-1287288` (16/16) | **The churn storm loses on every axis.** 149 netns add+del cycles in 240 s (one launch/s, each container: tcp-stress `both` with `-close` — 2500 LISTEN + 2500 client sockets, dead ~2.5 s, `--rm`): poll_sockets 237→7875 mid-storm, daemon CPU 111–114% (of 4 vCPUs; bound 250%), victim records flowing MID-storm, `reconcile_incomplete_total` 0→0 (the 1 s scan budget never tripped). Post-storm convergence (measured: in-flight goroutines take ~2 min to drain — run 1's +15 at 30 s settled to baseline−1 by 4 min, flat — convergence waits, not fixed sleeps): **go_goroutines 51→51, process_open_fds 53→53, poll_sockets back to 245** (a leaked dead netns counts as unknown = −maxRecordsPerNetns = 1M sockets in the gauge, so baseline-level = the map drained). No FD leak, no goroutine leak, no restart. **Finding (#370): the row's core mechanism — netns add/del under churn — is invisible in metrics**: `mapReconciler` stores/dels only fire on the 6 h background ticker (never in a 4-min run), and the per-poll reconcile (the ACTUAL discovery path, `reconcileBeforePoll` — `reconcile/start` +14730 over the storm) returns its deltas uncounted. The 24 h variant is env-gated (`RT_CHURN_SECS=86400`, never a matrix default); all asserts are duration-agnostic. Harness lesson: `A && B &` backgrounds the whole chain — launch runs with bare `nohup … &` only. | +| rt-11-8 | 2026-11-30 | bridge+raw+plain, self-churn (stated vantage: the tenant-with-deployment-rights position — a plain container cannot restart itself; that is not the mechanism under test) | BLOCKED | — | `20261130T042718-848ebbe00-1464077` (18/18) | **Self-churn does not even register.** 20 `docker restart -t 0 rt-attacker` cycles (~4.5 s apart), each re-packing 10000 sockfill loopback pairs (poll_sockets 241→20244): mid-storm victim coverage lag **0 s** (the row's verdict criterion), reconcile `complete` p99 **0.00032 s** (the 1 s reconcileTimeout budget is 3000x above), victim records flowing mid-storm, and post-storm go_goroutines 51→51 / process_open_fds 53→53 / poll_sockets 250 (the map drained; ~20 000 attacker sockets gone), `netns_dropped_total{add_rate}`=0 (the 256-adds/reconcile cap never approached), `reconcile_incomplete_total`=0, RestartCount=0. The reconcile scan is over ~8 netns — the restart churn is noise to it. The rt-4-6 observability finding (#370) applies verbatim: the stores/dels counters stay 0 in this shape. | +| rt-4-8 | 2026-11-30 | bridge+raw+plain, XTCP2_CPUS=2 (the cgroup-cap deploy axis), ATTACKER=admin (TriggerPollBurst is an admin RPC) | BLOCKED | — | `20261130T045657-848ebbe00-1525702` (16/16) | **The quota holds the line; the amplification lands in records, not CPU.** The admin sets the 1 s floor (SetPollFrequency 1 s/500 ms — the floor rt-3-3 landed) and runs TriggerPollBurst 120×1 s under a 2-CPU quota (NanoCpus=2000000000 verified on the container): record rate 116→491 rec/s (**4.2×**, the full-dump-per-poll cost), daemon CPU **130.9%/132.0%** under the burst vs 116% baseline — inside the quota bound (< 210% of the 4-vCPU host) — RSS 24453→27002 kB (no OOM-kill), metrics answers through the burst, post-burst rate settles (491→344→ the 2 s restore), no restart, gRPC Get ok after. The nuance the row now answers: at this population the burst multiplies RECORDS, not CPU (116→131% CPU for 4.2× records — polling is cheap); the quota is the right protection for the CPU leg, and the record-volume residual is #342's family (the burst's own `-count` bounds it). Prod guidance: pin `XTCP2_CPUS` — the default deploy is unlimited. | - Severity scale: docs/redteam-plan.md §severity. - Rows are appended, never edited, so the log doubles as the program's diff --git a/vagrant/scenarios/rt-11-8-self-churn.sh b/vagrant/scenarios/rt-11-8-self-churn.sh new file mode 100644 index 000000000..c0ea937e3 --- /dev/null +++ b/vagrant/scenarios/rt-11-8-self-churn.sh @@ -0,0 +1,287 @@ +#!/usr/bin/env bash +# vagrant/scenarios/rt-11-8-self-churn.sh — RT-11: self-churn and +# reconcile amplification (docs/redteam-plan.md row rt-11-8, task 4.6). +# +# THE PREMISE: a co-tenant attacks its OWN footprint — `docker restart` +# loops on its own container plus rapid socket churn inside it. Every +# restart is a netns remove+add through the daemon's reconcile (which runs +# before each poll), a fresh dockermeta lookup, and — once the workload +# re-packs its sockets after each restart (real pods re-dial on boot) — a +# full inet_diag dump of ~20K sockets, again and again. Add the AI098 +# shape (TODO-SOON: a netns vanished mid-walk must be a normal retry, not +# a warning storm) and the row's question: does the churn burn the cycle +# and lag the VICTIM namespaces' coverage? +# +# THE VERDICT CRITERIA (the row): bounded reconcile cost, no coverage lag +# on victim namespaces. +# +# VANTAGE: the restart loop is driven host-side by the harness — the +# tenant-with-deployment-rights position (a plain container cannot restart +# itself; that is not the mechanism under test). The sockfill re-pack per +# cycle IS the container's own workload (docker exec from inside the +# container would do the same); it models a pod that rebuilds its sockets +# on every boot. +set -euo pipefail + +: "${XTCP2_MODE:=bridge}" +: "${XTCP2_AUTH:=raw}" +: "${XTCP2_ATTACKER:=plain}" +XTCP2_EXPECT="${XTCP2_EXPECT:-BLOCKED}" + +# storm shape (env-tunable; defaults sized for a ~4 min matrix row) +RT_RESTARTS="${RT_RESTARTS:-20}" # restart cycles +RT_PAIRS="${RT_PAIRS:-10000}" # loopback pairs re-packed per cycle (2x = sockets) + +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/matrix.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/evidence.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/ssh.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/deploy.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/invariant.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/assert.sh" + +xtcp2_matrix_defaults +xtcp2_preflight +evidence_init + +echo "rt-11-8: evidence in $RT_EVIDENCE ($RT_RESTARTS restarts x $RT_PAIRS pairs)" + +# --- helpers ----------------------------------------------------------------------- + +mval() { # mval — one metrics series' value (absent = 0) + local v + v="$(vm_exec victim "curl -s -m 6 -H 'Authorization: Bearer $RT_READ_TOKEN' http://127.0.0.1:9088/metrics | grep '$1' | grep -v '^#' | grep -oE '[0-9.e+-]+\$' | head -1" || true)" + echo "${v:-0}" +} + +msum() { # msum — SUM of all matching series (label fan-out) + vm_exec victim "curl -s -m 6 -H 'Authorization: Bearer $RT_READ_TOKEN' http://127.0.0.1:9088/metrics | grep '$1' | grep -v '^#' | grep -oE '[0-9.e+-]+\$' | awk '{s+=\\$1} END{print s+0}'" || echo 0 +} + +qval() { # qval — a summary quantile's value + vm_exec victim "curl -s -m 6 -H 'Authorization: Bearer $RT_READ_TOKEN' http://127.0.0.1:9088/metrics | grep '$1' | grep 'quantile=\"$2\"' | grep -v '^#' | grep -oE '[0-9.e+]+\$' | head -1" || echo 0 +} + +daemon_restarts() { + vm_exec victim "sudo docker inspect rt-xtcp2 --format '{{.RestartCount}}'" +} + +# victim_lag_s: worst age of the two victim namespaces' newest records at +# the catcher (the rt-11-4 helper verbatim — one line: multi-line payloads +# do not survive vm_exec_root's %q layer). +victim_lag_s() { # victim_lag_s + vm_exec_root victim "tail -n 50000 /var/lib/xtcp2-catcher/records.jsonl | python3 -c \"import json,time,sys; ids={'$1','$2'}; last={}; [last.__setitem__(r['netns'], max(last.get(r['netns'],0), int(r.get('timestampNs','0')))) for r in (json.loads(l) for l in sys.stdin if l.strip()) if r.get('netns') in ids]; now=time.time_ns(); print(max([0]+[(now-t)//10**9 for t in last.values()]))\"" || echo 999 +} + +victim_ids() { + vm_exec victim "sudo docker inspect rt-work-1 rt-work-2 --format '{{.Id}}' | cut -c1-12" +} + +# ============================================================================= +# deploy + baseline +# ============================================================================= + +xtcp2_deploy victim attacker +wait_for 120 "daemon answers on the victim VM" vm_exec victim \ + "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:9088/metrics | grep -qE '^(200|401|403)\$'" +victim_still_reporting_tap +xtcp2_victim_read_token + +ids="$(victim_ids)" +W1="$(echo "$ids" | head -1)" +W2="$(echo "$ids" | tail -1)" +echo "rt-11-8: victim netns ids: $W1 $W2" + +B_FDS="$(mval 'process_open_fds')" +B_GORO="$(mval 'go_goroutines')" +B_Q99="$(qval 'reconcile' '0.99')" +B_LAG="$(victim_lag_s "$W1" "$W2")" +B_SOCK="$(mval 'poll_sockets ')" +ok "baseline: FDs=$B_FDS goroutines=$B_GORO poll_sockets=$B_SOCK reconcile p99=${B_Q99}s lag=${B_LAG}s" +# the attacker's own workload: sockfill packed once (the restart loop +# re-packs it per cycle; the binary survives restarts in the RW layer) +vm_exec victim "sudo docker cp /opt/xtcp2-redteam/bin/sockfill rt-attacker:/tmp/sockfill" >/dev/null +vm_exec victim "sudo docker exec rt-attacker sh -c 'nohup /tmp/sockfill -pairs $RT_PAIRS -perPort 20000 > /tmp/sf.log 2>&1 &'" >/dev/null +wait_for 120 "the first sockfill pack holds the pairs open" vm_exec victim \ + "sudo docker exec rt-attacker grep -q SOCKFILL_READY /tmp/sf.log" +SOCKS0="$(mval 'poll_sockets ')" +ok "the attacker netns is packed: poll_sockets $B_SOCK -> $SOCKS0 (~$((RT_PAIRS * 2)) sockets of its own)" + +# ============================================================================= +# the storm: restart loop + per-cycle re-pack (host-side driver, bare nohup) +# ============================================================================= + +SELF_SCRIPT="$(cat <<'SELF' +#!/bin/sh +# rt-11-8 self-churn driver: restart the ATTACKER's own container in a +# tight loop; its workload re-packs V_PAIRS loopback pairs after every +# boot (a real pod re-dials). Each cycle: netns del + add (reconcile, +# dockermeta), a fresh full dump of ~2x V_PAIRS sockets. +CYCLES=V_CYCLES +PAIRS=V_PAIRS +i=0 +while [ $i -lt $CYCLES ]; do + i=$((i + 1)) + docker restart -t 0 rt-attacker >/dev/null 2>&1 || true + sleep 1 + docker exec rt-attacker sh -c "nohup /tmp/sockfill -pairs $PAIRS -perPort 20000 >/tmp/sf.log 2>&1 &" >/dev/null 2>&1 || true + sleep 3 + echo "restart=$i" +done +echo "SELFCHURN-DONE cycles=$i" +SELF +)" +SELF_B64="$(printf '%s\n' "$SELF_SCRIPT" \ + | sed "s/V_CYCLES/$RT_RESTARTS/; s/V_PAIRS/$RT_PAIRS/" | base64 -w0)" +vm_exec_root victim "echo '$SELF_B64' | base64 -d > /tmp/rt-11-8-self.sh && chmod +x /tmp/rt-11-8-self.sh" +vm_exec_root victim "nohup sh /tmp/rt-11-8-self.sh >/tmp/rt-11-8-self.log 2>&1 &" >/dev/null + +# measure under load: past the halfway point of the loop +HALF=$(( RT_RESTARTS * 4 / 2 )) +sleep "$HALF" + +MID_LAG="$(victim_lag_s "$W1" "$W2")" +MID_Q99="$(qval 'reconcile' '0.99')" +echo "rt-11-8: mid-storm lag=${MID_LAG}s reconcile p99=${MID_Q99}s" + +if [ "$MID_LAG" -le 10 ] 2>/dev/null; then + ok "no coverage lag on victim namespaces mid-storm (worst victim record age ${MID_LAG}s, bound 10s)" +else + not_ok "victim coverage lagged ${MID_LAG}s mid-storm — the reconcile cycle burned the poll; see evidence" +fi + +# bounded reconcile cost: the reconcile's own budget is 1s +# (reconcileTimeout default); with ~8 netns the scan must stay in budget. +if awk "BEGIN{exit !($MID_Q99 <= 1.0)}"; then + ok "reconcile cost bounded mid-storm (complete p99 ${MID_Q99}s <= the 1s reconcileTimeout budget)" +else + not_ok "reconcile p99 ${MID_Q99}s exceeded the 1s budget mid-storm — see evidence" +fi + +# the invariant UNDER ATTACK +if victim_still_reporting; then + ok "victim still reporting MID-STORM (catcher grew over 6s while the attacker restarted itself)" +else + not_ok "victim records stalled mid-storm — see evidence" +fi + +# ============================================================================= +# wait out the loop, then the leak/drop asserts +# ============================================================================= + +wait_for $((RT_RESTARTS * 8 + 120)) "the self-churn driver finishes" vm_exec_root victim \ + "grep -q SELFCHURN-DONE /tmp/rt-11-8-self.log" + +CYCLES="$(vm_exec_root victim "grep -c '^restart=' /tmp/rt-11-8-self.log || true")" +CYCLES="${CYCLES:-0}" +echo "rt-11-8: driver ran $CYCLES/$RT_RESTARTS cycles" +if [ "$CYCLES" -ge $((RT_RESTARTS / 2)) ] 2>/dev/null; then + ok "the self-churn ran at scale: $CYCLES restart cycles, each re-packing ~$((RT_PAIRS * 2)) sockets" +else + not_ok "only $CYCLES of $RT_RESTARTS cycles ran — see evidence" +fi + +# the driver's LAST pack is still holding sockets (nohup'd inside the +# container, detached from the driver) — kill it so the drain asserts +# measure the daemon alone +vm_exec victim "sudo docker exec rt-attacker pkill -f sockfill" >/dev/null 2>&1 || true + +sleep 30 # first settle; the convergence helper below finishes the drain + +# settle_bound: poll up to 180s for a metric to converge <= bound (the +# rt-4-6 measurement: in-flight goroutines take ~2 min to drain, a leak +# never converges). +settle_bound() { # settle_bound + local v + for _ in $(seq 1 12); do + v="$(mval "$1")" + case "$v" in '' | *[!0-9.]*) v=999999 ;; esac + if awk "BEGIN{exit !($v <= $2)}"; then return 0; fi + sleep 15 + done + return 1 +} + +A_FDS="$(mval 'process_open_fds')" +A_GORO="$(mval 'go_goroutines')" +A_Q99="$(qval 'reconcile' '0.99')" +A_ADDRATE="$(msum 'netns_dropped_total{reason=\"add_rate\"}')" +A_INCOMPLETE="$(msum 'reconcile_incomplete')" +A_SOCK="$(mval 'poll_sockets ')" +echo "rt-11-8: post-storm FDs=$A_FDS goroutines=$A_GORO reconcile p99=$A_Q99 poll_sockets=$A_SOCK add_rate=$A_ADDRATE incomplete=$A_INCOMPLETE" + +if settle_bound 'go_goroutines' $((B_GORO + 10)); then + A_GORO="$(mval 'go_goroutines')" + ok "no goroutine leak: go_goroutines $B_GORO -> $A_GORO (converged <= baseline+10 after $CYCLES restarts)" +else + A_GORO="$(mval 'go_goroutines')" + not_ok "goroutine leak: go_goroutines $B_GORO -> $A_GORO never settled below baseline+10 — see evidence" +fi +if settle_bound 'process_open_fds' $((B_FDS + 30)); then + A_FDS="$(mval 'process_open_fds')" + ok "no FD leak: process_open_fds $B_FDS -> $A_FDS (converged <= baseline+30)" +else + A_FDS="$(mval 'process_open_fds')" + not_ok "FD leak: process_open_fds $B_FDS -> $A_FDS never settled below baseline+30 — see evidence" +fi + +# the netns map drained — proven by the socket gauge (a leaked dead netns +# counts as unknown = -maxRecordsPerNetns = 1M sockets in poll_sockets); the +# mapReconciler stores/dels counters are NOT usable here: the 6h background +# ticker never ticks in a 4-min run, and the per-poll reconcile (the ACTUAL +# discovery path) returns its deltas uncounted — the rt-4-6 observability +# finding applies verbatim. sockfill is killed above, so baseline is the +# honest target. +if settle_bound 'poll_sockets ' $((B_SOCK + 1000)); then + A_SOCK="$(mval 'poll_sockets ')" + ok "the netns map drained: poll_sockets back to $A_SOCK (baseline $B_SOCK, ~$((RT_PAIRS * 2)) attacker sockets gone)" +else + A_SOCK="$(mval 'poll_sockets ')" + not_ok "poll_sockets stuck at $A_SOCK — dead namespaces not forgotten; see evidence" +fi + +if [ "$A_ADDRATE" -eq 0 ] 2>/dev/null; then + ok "no add_rate drops: the restarts never hit the 256-adds-per-reconcile cap (netns_dropped_total add_rate=$A_ADDRATE)" +else + not_ok "netns_dropped add_rate=$A_ADDRATE — restart churn tripped the add cap; see evidence" +fi + +# ============================================================================= +# the invariant holds after the storm +# ============================================================================= + +victim_still_reporting_tap +FINAL_LAG="$(victim_lag_s "$W1" "$W2")" +if [ "$FINAL_LAG" -le 10 ] 2>/dev/null; then + ok "no coverage lag after the storm (worst victim record age ${FINAL_LAG}s)" +else + not_ok "victim coverage lagged ${FINAL_LAG}s after the storm — see evidence" +fi +code="$(vm_exec victim "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:9088/metrics")" +if [ "$code" = 200 ] || [ "$code" = 401 ] || [ "$code" = 403 ]; then + ok "the daemon is healthy after the storm (scrape $code)" +else + not_ok "scrape=$code after the storm — see evidence" +fi +RESTARTS="$(daemon_restarts)" +if [ "$RESTARTS" -eq 0 ]; then + ok "the daemon was never restarted (RestartCount=0)" +else + not_ok "the daemon restarted $RESTARTS times during the self-churn — see evidence" +fi + +# ============================================================================= +# teardown +# ============================================================================= + +vm_exec_root victim "pkill -f rt-11-8-self.sh" >/dev/null 2>&1 || true +vm_exec victim "sudo docker exec rt-attacker pkill -f sockfill" >/dev/null 2>&1 || true +vm_exec_root victim "cat /tmp/rt-11-8-self.log" >"$RT_EVIDENCE/self-churn.log" 2>/dev/null || true +vm_exec victim "sudo docker restart rt-attacker" >/dev/null 2>&1 || true + +finish rt-11-8 "$XTCP2_EXPECT" diff --git a/vagrant/scenarios/rt-4-6-namespace-churn.sh b/vagrant/scenarios/rt-4-6-namespace-churn.sh new file mode 100644 index 000000000..0e295e8b7 --- /dev/null +++ b/vagrant/scenarios/rt-4-6-namespace-churn.sh @@ -0,0 +1,302 @@ +#!/usr/bin/env bash +# vagrant/scenarios/rt-4-6-namespace-churn.sh — RT-4: namespace/socket +# churn storm from co-tenant containers (docs/redteam-plan.md row rt-4-6, +# task 4.6). +# +# THE PREMISE: a co-tenant fleet churns pods — every `docker run` is a +# netns the daemon must discover (reconcile runs before each poll), dump +# (full inet_diag walk of whatever the pod's sockets are), and forget (map +# del); every socket inside adds/removes records. Weaponized: a workload +# whose pods live ~2.5 s and carry 5000 sockets each, one launch per +# second, sustained. The row's verdict: no fd leak, no goroutine leak, +# bounded CPU, daemon survives (ties into TODO-SOON AI098: a vanished +# netdev mid-walk must be a normal retry, not a warning storm). +# +# THE MECHANISM UNDER TEST: mapReconciler churn (stores/dels), discovery +# (dockermeta per new container id), and the per-poll reconcile — NOT the +# dump size (rt-11-4 measured 300K sockets in ONE netns as survivable; +# here it is 5K sockets across ever-new netns at ~1 netns add+del/s). +# +# VANTAGE (stated plainly): the storm is driven host-side by the harness — +# the fleet operator's position. A PLAIN attacker container cannot create +# netns (no CAP_SYS_ADMIN; NET_ADMIN does not grant it either — measured +# in rt-11-7's ladder). The row's real-world shape is a hostile TENANT +# with deployment rights (CI/CD abuse) or a churn-bug fleet: the daemon +# must be robust to churn regardless of who caused it, which is what this +# measures. +# +# THE 24 H VARIANT is env-gated, never a matrix default (task 4.6): +# RT_CHURN_SECS=86400 nix run .#redteam-rt-4-6 +# All asserts are duration-agnostic (ratios and bounds, never absolutes +# that only hold at 240 s). +set -euo pipefail + +: "${XTCP2_MODE:=bridge}" +: "${XTCP2_AUTH:=raw}" +: "${XTCP2_ATTACKER:=plain}" +XTCP2_EXPECT="${XTCP2_EXPECT:-BLOCKED}" + +# storm shape (env-tunable; defaults sized for a ~4 min matrix row) +RT_CHURN_SECS="${RT_CHURN_SECS:-240}" # storm duration; 86400 = the 24 h soak +RT_CHURN_SLOTS="${RT_CHURN_SLOTS:-4}" # concurrent churn containers +RT_CHURN_COUNT="${RT_CHURN_COUNT:-2500}" # sockets per container half (2x = live sockets) +RT_CHURN_CYCLE="${RT_CHURN_CYCLE:-1}" # seconds between launches + +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/matrix.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/evidence.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/ssh.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/deploy.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/invariant.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/assert.sh" + +xtcp2_matrix_defaults +xtcp2_preflight +evidence_init + +echo "rt-4-6: evidence in $RT_EVIDENCE (churn ${RT_CHURN_SECS}s, ${RT_CHURN_SLOTS} slots x ~$((RT_CHURN_COUNT * 2)) sockets)" + +# --- helpers ----------------------------------------------------------------------- + +mval() { # mval — one metrics series' value (absent = 0) + local v + v="$(vm_exec victim "curl -s -m 6 -H 'Authorization: Bearer $RT_READ_TOKEN' http://127.0.0.1:9088/metrics | grep '$1' | grep -v '^#' | grep -oE '[0-9.e+-]+\$' | head -1" || true)" + echo "${v:-0}" +} + +msum() { # msum — SUM of all matching series (label fan-out, + # e.g. reconcile_incomplete_total{reason=...}: one line per reason) + vm_exec victim "curl -s -m 6 -H 'Authorization: Bearer $RT_READ_TOKEN' http://127.0.0.1:9088/metrics | grep '$1' | grep -v '^#' | grep -oE '[0-9.e+-]+\$' | awk '{s+=\$1} END{print s+0}'" || echo 0 +} + +# churn_socket_peak: the highest poll_sockets gauge over a sampling window +# (the poll runs every 2 s and a churn container lives ~2.5 s, so a few +# samples are needed to catch the peak). +poll_sockets_peak() { # poll_sockets_peak + local i v max=0 + for i in $(seq 1 "$1"); do + v="$(mval 'poll_sockets ')" + case "$v" in '' | *[!0-9.]*) v=0 ;; esac + if awk "BEGIN{exit !($v > $max)}"; then max=$v; fi + [ "$i" -eq "$1" ] || sleep "$2" + done + echo "$max" +} + +daemon_cpu_pct() { + vm_exec victim "sudo docker stats --no-stream --format '{{.CPUPerc}}' rt-xtcp2" | grep -oE '^[0-9.]+' || echo 0 +} + +daemon_restarts() { + vm_exec victim "sudo docker inspect rt-xtcp2 --format '{{.RestartCount}}'" +} + +# ============================================================================= +# deploy + baseline +# ============================================================================= + +xtcp2_deploy victim attacker +wait_for 120 "daemon answers on the victim VM" vm_exec victim \ + "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:9088/metrics | grep -qE '^(200|401|403)\$'" +victim_still_reporting_tap +xtcp2_victim_read_token + +B_FDS="$(mval 'process_open_fds')" +B_GORO="$(mval 'go_goroutines')" +B_SOCK="$(mval 'poll_sockets ')" +B_INCOMPLETE="$(msum 'reconcile_incomplete')" +B_RECONCILES="$(mval 'variable=\"start\"')" # reconcile/start: one per poll +B_CPU="$(daemon_cpu_pct)" +ok "baseline: FDs=$B_FDS goroutines=$B_GORO poll_sockets=$B_SOCK cpu=${B_CPU}% incomplete=$B_INCOMPLETE reconciles=$B_RECONCILES" + +# ============================================================================= +# the storm (host-side driver, bare nohup so the ssh session returns — the +# rt-11-6 lesson; base64 delivery because vagrant ssh has no stdin) +# ============================================================================= + +CHURN_SCRIPT="$(cat <<'CHURN' +#!/bin/sh +# rt-4-6 churn driver: launch a fresh short-lived socket-heavy container +# every V_CYCLE seconds across V_SLOTS name slots. Each container: tcp-stress +# 'both' with -close — the server half opens V_COUNT LISTEN sockets, the +# client half dials V_COUNT once, closes (TIME_WAIT), exits as PID 1, which +# takes the container and its whole netns with it: netns add, ~2x V_COUNT +# sockets, netns del, repeat. +SLOTS=V_SLOTS +COUNT=V_COUNT +CYCLE=V_CYCLE +END=$(( $(date +%s) + V_SECS )) +i=0 +while [ "$(date +%s)" -lt "$END" ]; do + i=$((i + 1)) + s=$(( i % SLOTS + 1 )) + docker rm -f rt-churn-$s >/dev/null 2>&1 || true + docker run -d --rm --name rt-churn-$s \ + -e TCP_MODE=both -e TCP_COUNT=$COUNT -e TCP_SLEEP=100ms \ + -e 'TCP_CLIENT_ARGS=-close' \ + xtcp2-tcp-stress:latest >/dev/null 2>&1 || true + echo "cycle=$i" + sleep "$CYCLE" +done +echo "CHURN-DONE cycles=$i" +CHURN +)" +CHURN_B64="$(printf '%s\n' "$CHURN_SCRIPT" \ + | sed "s/V_SECS/$RT_CHURN_SECS/; s/V_SLOTS/$RT_CHURN_SLOTS/; s/V_COUNT/$RT_CHURN_COUNT/; s/V_CYCLE/$RT_CHURN_CYCLE/" \ + | base64 -w0)" +vm_exec_root victim "echo '$CHURN_B64' | base64 -d > /tmp/rt-4-6-churn.sh && chmod +x /tmp/rt-4-6-churn.sh" +vm_exec_root victim "nohup sh /tmp/rt-4-6-churn.sh >/tmp/rt-4-6-churn.log 2>&1 &" >/dev/null + +# give the storm ~30 s to spin up (a few slots live at once), then measure +# under load. +sleep 30 +SOCK_PEAK="$(poll_sockets_peak 5 3)" +CPU1="$(daemon_cpu_pct)" +sleep 5 +CPU2="$(daemon_cpu_pct)" +echo "rt-4-6: mid-storm poll_sockets peak=$SOCK_PEAK (baseline $B_SOCK) cpu=$CPU1%/$CPU2%" + +if [ "$(printf '%s' "$SOCK_PEAK" | cut -d. -f1)" -ge $((B_SOCK + 2500)) ] 2>/dev/null; then + ok "the storm is real: poll_sockets $B_SOCK -> $SOCK_PEAK mid-storm (short-lived netns with thousands of sockets each)" +else + not_ok "poll_sockets peak only $SOCK_PEAK vs baseline $B_SOCK — the churn may not have been visible; see evidence" +fi + +# the invariant UNDER ATTACK: records keep flowing mid-storm +if victim_still_reporting; then + ok "victim still reporting MID-STORM (catcher grew over 6s while netns churned)" +else + not_ok "victim records stalled mid-storm — see evidence" +fi + +# bounded CPU: the daemon must not peg the host doing churn bookkeeping +# (4 vCPUs on the victim; 250% = it must leave more than half the host alone) +if [ "${CPU1%.*}" -lt 250 ] 2>/dev/null && [ "${CPU2%.*}" -lt 250 ] 2>/dev/null; then + ok "daemon CPU bounded mid-storm (${CPU1}% then ${CPU2}%, < 250% of 4 vCPUs)" +else + not_ok "daemon CPU ${CPU1}%/${CPU2}% mid-storm — unbounded; see evidence" +fi + +# ============================================================================= +# wait out the storm, then the leak asserts +# ============================================================================= + +wait_for $((RT_CHURN_SECS + 120)) "the churn driver finishes" vm_exec_root victim \ + "grep -q CHURN-DONE /tmp/rt-4-6-churn.log" + +CYCLES="$(vm_exec_root victim "grep -c '^cycle=' /tmp/rt-4-6-churn.log || true")" +CYCLES="${CYCLES:-0}" +echo "rt-4-6: driver ran $CYCLES cycles (target ~$((RT_CHURN_SECS / RT_CHURN_CYCLE)))" +if [ "$CYCLES" -ge $((RT_CHURN_SECS / RT_CHURN_CYCLE / 2)) ] 2>/dev/null; then + ok "the churn ran at scale: $CYCLES netns add+del cycles" +else + not_ok "only $CYCLES churn cycles — the driver under-ran; see evidence" +fi + +# settle: in-flight work drains over ~2 min (measured: goroutines peaked at +# baseline+15 at 30 s, settled to baseline-1 by 4 min and stayed flat — the +# transient is the last churn containers' dump/flush goroutines, not a +# leak). Convergence wait, not a fixed sleep: a leak never converges. +settle_bound() { # settle_bound — poll up to 180s for <= bound + local i v + for i in $(seq 1 12); do + v="$(mval "$1")" + case "$v" in '' | *[!0-9.]*) v=999999 ;; esac + if awk "BEGIN{exit !($v <= $2)}"; then return 0; fi + sleep 15 + done + return 1 +} + +B_RECONCILES="${B_RECONCILES:-0}" +A_RECONCILES="$(mval 'variable=\"start\"')" + +if settle_bound 'go_goroutines' $((B_GORO + 10)); then + A_GORO="$(mval 'go_goroutines')" + ok "no goroutine leak: go_goroutines $B_GORO -> $A_GORO (converged <= baseline+10 after $CYCLES netns cycles)" +else + A_GORO="$(mval 'go_goroutines')" + not_ok "goroutine leak: go_goroutines $B_GORO -> $A_GORO never settled below baseline+10 — see evidence" +fi +if settle_bound 'process_open_fds' $((B_FDS + 30)); then + A_FDS="$(mval 'process_open_fds')" + ok "no FD leak: process_open_fds $B_FDS -> $A_FDS (converged <= baseline+30)" +else + A_FDS="$(mval 'process_open_fds')" + not_ok "FD leak: process_open_fds $B_FDS -> $A_FDS never settled below baseline+30 — see evidence" +fi + +# the netns map drained — proven by the socket gauge, not mapReconciler +# counters (see the observability finding below): every tracked namespace's +# sockstat feeds poll_sockets, and an entry that leaked past its dead netns +# counts as unknown = -maxRecordsPerNetns (1M), so a single leaked entry +# would spike the gauge; baseline-level means every churn netns was +# forgotten. +if settle_bound 'poll_sockets ' $((B_SOCK + 500)); then + A_SOCK="$(mval 'poll_sockets ')" + ok "the netns map drained: poll_sockets back to $A_SOCK (baseline $B_SOCK; a leaked dead netns would count 1M unknown sockets)" +else + A_SOCK="$(mval 'poll_sockets ')" + not_ok "poll_sockets stuck at $A_SOCK vs baseline $B_SOCK — dead namespaces not forgotten; see evidence" +fi + +# OBSERVABILITY FINDING (measured, asserted): the row's core mechanism — +# netns add/del under churn — is invisible in metrics in the default shape. +# mapReconciler's stores/dels counters only fire on the 6h background +# ticker (never in a 4-min run); the per-poll reconcile (reconcile/start, +# one per poll — the ACTUAL discovery path, reconcileBeforePoll) returns its +# deltas uncounted (poller.go reconcileThenPoll logs them at debug>10 and +# drops them). +A_STORES="$(mval 'variable=\"stores\"')" +A_DELS="$(mval 'variable=\"dels\"')" +RECON_DELTA=$((A_RECONCILES - B_RECONCILES)) +echo "rt-4-6: post-storm reconcile/start delta=$RECON_DELTA mapReconciler stores=$A_STORES dels=$A_DELS" +if [ "$RECON_DELTA" -ge $((CYCLES / 2)) ] 2>/dev/null && [ "$A_STORES" -eq 0 ] && [ "$A_DELS" -eq 0 ]; then + ok "the churn reconciled per-poll (reconcile/start +$RECON_DELTA) but netns add/del is UNCOUNTED in this shape (mapReconciler stores/dels=0: the 6h ticker never ticks; the per-poll deltas are dropped) — observability gap, filed" +else + not_ok "reconcile/start delta=$RECON_DELTA vs $CYCLES cycles, stores=$A_STORES dels=$A_DELS — the churn may not have reached the reconciler; see evidence" +fi + +A_INCOMPLETE="$(msum 'reconcile_incomplete')" +if [ "$A_INCOMPLETE" -le "$B_INCOMPLETE" ] 2>/dev/null; then + ok "every reconcile completed within its budget (reconcile_incomplete_total $B_INCOMPLETE -> $A_INCOMPLETE)" +else + not_ok "reconcile_incomplete_total grew $B_INCOMPLETE -> $A_INCOMPLETE — the 1s scan budget tripped on churn; see evidence" +fi + +# ============================================================================= +# the invariant holds after the storm +# ============================================================================= + +victim_still_reporting_tap +code="$(vm_exec victim "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:9088/metrics")" +if [ "$code" = 200 ] || [ "$code" = 401 ] || [ "$code" = 403 ]; then + ok "the daemon is healthy after the storm (scrape $code)" +else + not_ok "scrape=$code after the storm — see evidence" +fi +RESTARTS="$(daemon_restarts)" +if [ "$RESTARTS" -eq 0 ]; then + ok "the daemon was never restarted (RestartCount=0)" +else + not_ok "the daemon restarted $RESTARTS times during the churn — see evidence" +fi + +# ============================================================================= +# teardown +# ============================================================================= + +vm_exec_root victim "pkill -f rt-4-6-churn.sh" >/dev/null 2>&1 || true +i=1 +while [ "$i" -le "$RT_CHURN_SLOTS" ]; do + vm_exec victim "sudo docker rm -f rt-churn-$i" >/dev/null 2>&1 || true + i=$((i + 1)) +done +vm_exec_root victim "cat /tmp/rt-4-6-churn.log" >"$RT_EVIDENCE/churn.log" 2>/dev/null || true + +finish rt-4-6 "$XTCP2_EXPECT" diff --git a/vagrant/scenarios/rt-4-8-poll-amplification-cpu-quota.sh b/vagrant/scenarios/rt-4-8-poll-amplification-cpu-quota.sh new file mode 100644 index 000000000..d2648afac --- /dev/null +++ b/vagrant/scenarios/rt-4-8-poll-amplification-cpu-quota.sh @@ -0,0 +1,216 @@ +#!/usr/bin/env bash +# vagrant/scenarios/rt-4-8-poll-amplification-cpu-quota.sh — RT-4: +# admin-triggered poll amplification, cgroup-protection variant +# (docs/redteam-plan.md row rt-4-8, task 4.8; premortem refocus). +# +# THE PREMISE (the row): an admin (or anything holding the admin credential) +# triggers poll bursts — TriggerPollBurst at the 1 s floor, the fastest +# honored cadence — multiplying the full-dump-per-poll work. rt-3-3 +# measured the mechanism (3x CPU at 1 s) with NO quota: the daemon could +# take whatever share of the host it wanted. What rt-3-3 did NOT test is +# the row's second clause: cgroup protection. This scenario is the same +# burst under a 2-CPU quota (the XTCP2_CPUS deploy axis, --cpus=2): the +# question is whether the amplification is bounded by the quota. +# +# THE ANSWER SHAPE (measured before the asserts were written — run 1): +# the quota caps the CPU (docker stats <= ~200% of a 4-vCPU host), the +# API stays 200, no OOM-kill, RSS flat — the HOST is protected. The +# residual is the row's own arithmetic: the RECORD RATE still multiplies +# with the poll rate (quota or not — polling is cheap CPU-wise at this +# population), so the sink/retention cost of a burst is not a CPU matter. +# That residual is #342's family (record volume), and the burst counter +# bounds it (TriggerPollBurst -count). +# +# VANTAGE: the burst is admin-triggered (TriggerPollBurst/SetPollFrequency +# are admin-RPCs; the 1 s floor landed in rt-3-3 and is asserted there). +# The cgroup quota is the OPERATOR's defense — the §29 deploy axis +# XTCP2_CPUS, default 0 = unlimited; this scenario pins 2 to measure the +# protection working. +set -euo pipefail + +: "${XTCP2_MODE:=bridge}" +: "${XTCP2_AUTH:=raw}" +: "${XTCP2_ATTACKER:=admin}" +: "${XTCP2_CPUS:=2}" # the row: the cgroup-cap variant (default 0 = unlimited) +XTCP2_EXPECT="${XTCP2_EXPECT:-BLOCKED}" + +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/matrix.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/evidence.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/ssh.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/deploy.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/invariant.sh" +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/../lib/assert.sh" + +xtcp2_matrix_defaults +xtcp2_preflight +evidence_init + +echo "rt-4-8: evidence in $RT_EVIDENCE (XTCP2_CPUS=$XTCP2_CPUS quota, admin burst)" + +# --- helpers ----------------------------------------------------------------------- + +daemon_cpu_pct() { + vm_exec victim "sudo docker stats --no-stream --format '{{.CPUPerc}}' rt-xtcp2" | grep -oE '^[0-9.]+' || echo 0 +} + +daemon_rss_kb() { + vm_exec victim "sudo docker stats --no-stream --format '{{.MemUsage}}' rt-xtcp2" \ + | grep -oE '^[0-9.]+' | awk '{printf "%d", $1 * 1024}' +} + +daemon_oomkilled() { + vm_exec victim "sudo docker inspect rt-xtcp2 --format '{{.State.OOMKilled}}'" +} + +daemon_restarts() { + vm_exec victim "sudo docker inspect rt-xtcp2 --format '{{.RestartCount}}'" +} + +scrape_code() { + vm_exec victim "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:9088/metrics" +} + +# rate : victim-catcher records/s over the last window +rate() { + local secs="$1" a b + a="$(catcher_lines)" + sleep "$secs" + b="$(catcher_lines)" + echo $(( (b - a) / secs )) +} + +# ============================================================================= +# deploy (the quota is the deploy axis) + baseline +# ============================================================================= + +xtcp2_deploy victim attacker +wait_for 120 "daemon answers on the victim VM" vm_exec victim \ + "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:9088/metrics | grep -qE '^(200|401|403)\$'" +victim_still_reporting_tap + +QUOTA_SET="$(vm_exec victim "sudo docker inspect rt-xtcp2 --format '{{.HostConfig.NanoCpus}}'")" +if [ "${QUOTA_SET:-0}" -ge 2000000000 ] 2>/dev/null; then + ok "the quota is set on the daemon container (NanoCpus=$QUOTA_SET = $XTCP2_CPUS CPUs)" +else + not_ok "no cpu quota on the daemon container (NanoCpus=${QUOTA_SET:-unset}) — the XTCP2_CPUS axis did not deploy; see evidence" +fi + +admin_token="$(vm_exec victim 'sudo docker exec rt-attacker cat /run/secrets/admin')" +[ -n "$admin_token" ] || xtcp2_die 'no admin token in the attacker container' +CTL=/opt/xtcp2-redteam/bin/xtcp2ctl +CTL_ARGS="-network tcp -target 192.168.142.10 -port 8889 -auth-token" + +B_RATE="$(rate 12)" +B_CPU="$(daemon_cpu_pct)" +B_RSS="$(daemon_rss_kb)" +ok "baseline: rate=${B_RATE} rec/s cpu=${B_CPU}% rss=${B_RSS}kB" + +# ============================================================================= +# the burst (admin-triggered, 120 polls at the 1 s floor = 120 s of +# full-dump-per-poll at the maximum honored cadence) +# ============================================================================= + +# the burst needs interval > poll_timeout (grpc_configService.go: the RPC +# validates it so each poll completes before the next fires); the daemon +# deploys with the 5s default, so set the floor cadence first (the same +# SetPollFrequency rt-3-3 used: 1s/500ms — the floor the poll-frequency fix +# landed) +vm_exec attacker "$CTL set-poll-frequency $CTL_ARGS '$admin_token' -frequency 1s -timeout 500ms" \ + >"$RT_EVIDENCE/set-poll-frequency.log" 2>&1 || true +if grep -q "ok:" "$RT_EVIDENCE/set-poll-frequency.log"; then + ok "SetPollFrequency to the 1 s floor accepted (timeout 500ms, so a 1 s burst interval is legal)" +else + not_ok "SetPollFrequency rejected — see evidence" +fi + +vm_exec attacker "$CTL poll-burst $CTL_ARGS '$admin_token' -count 120 -interval 1s" \ + >"$RT_EVIDENCE/poll-burst.log" 2>&1 || true +if grep -q "ok: burst" "$RT_EVIDENCE/poll-burst.log"; then + ok "the admin burst was accepted and ran (120 polls at the 1 s floor)" +else + not_ok "the poll burst did not run — see evidence" +fi + +# measure DURING the burst: the CPU samples and the record rate over the +# same window (the burst writes one poll per second for ~2 min) +CPU1="$(daemon_cpu_pct)" +R_RATE="$(rate 20)" +CPU2="$(daemon_cpu_pct)" +R_RSS="$(daemon_rss_kb)" +echo "rt-4-8: mid-burst cpu=$CPU1%/$CPU2% rate=${R_RATE} rec/s rss=${R_RSS}kB (baseline ${B_RATE} rec/s, ${B_RSS}kB)" + +if [ "${R_RATE:-0}" -ge $((B_RATE * 2)) ] 2>/dev/null; then + ok "the amplification is real: record rate ${B_RATE} -> ${R_RATE} rec/s under the burst (the full-dump-per-poll cost)" +else + not_ok "record rate only ${B_RATE} -> ${R_RATE} rec/s — the burst may not have amplified; see evidence" +fi + +# THE ROW'S CLAUSE: the quota bounds the CPU. 4 vCPUs on the victim; the +# 2-CPU quota caps docker stats at ~200%; slack for the sampling window. +if [ "${CPU1%.*}" -le 210 ] 2>/dev/null && [ "${CPU2%.*}" -le 210 ] 2>/dev/null; then + ok "cgroup protection: daemon CPU ${CPU1}% then ${CPU2}% under the burst, inside the ${XTCP2_CPUS}-CPU quota (< 210% of the 4-vCPU host)" +else + not_ok "daemon CPU ${CPU1}%/${CPU2}% exceeded the ${XTCP2_CPUS}-CPU quota bound — see evidence" +fi + +if [ "${CPU1%.*}" -ge 20 ] 2>/dev/null || [ "${CPU2%.*}" -ge 20 ] 2>/dev/null; then + ok "the daemon was actually busy under the burst (>= 20% CPU — the quota test measured a loaded daemon, not an idle one)" +else + not_ok "daemon CPU only ${CPU1}%/${CPU2}% — the burst never loaded the daemon; see evidence" +fi + +if [ "$R_RSS" -le $((B_RSS + 65536)) ] 2>/dev/null; then + ok "no memory blowout: RSS $B_RSS -> $R_RSS kB (<= baseline+64 MiB under the burst)" +else + not_ok "RSS $B_RSS -> $R_RSS kB under the burst — see evidence" +fi +if [ "$(daemon_oomkilled)" = false ]; then + ok "no OOM-kill (State.OOMKilled=false)" +else + not_ok "the daemon was OOM-killed under the burst — see evidence" +fi +code="$(scrape_code)" +if [ "$code" = 200 ] || [ "$code" = 401 ] || [ "$code" = 403 ]; then + ok "metrics answers through the burst (scrape $code)" +else + not_ok "scrape=$code during the burst — see evidence" +fi + +# ============================================================================= +# after the burst: healthy, restored, bounded +# ============================================================================= + +# restore the harness defaults (poll 2s / timeout 1s — the rt-3-3 restore) +vm_exec attacker "$CTL set-poll-frequency $CTL_ARGS '$admin_token' -frequency 2s -timeout 1s" \ + >"$RT_EVIDENCE/restore.log" 2>&1 || true + +sleep 10 # let the burst drain +A_RATE="$(rate 12)" +A_CPU="$(daemon_cpu_pct)" +A_RSS="$(daemon_rss_kb)" +echo "rt-4-8: post-burst rate=${A_RATE} rec/s cpu=${A_CPU}% rss=${A_RSS}kB" +if [ "$A_RATE" -le $((B_RATE * 3)) ] 2>/dev/null; then + ok "the record rate settles back (post-burst ${A_RATE} rec/s vs baseline ${B_RATE})" +else + not_ok "record rate still ${A_RATE} rec/s post-burst vs baseline ${B_RATE} — see evidence" +fi +victim_still_reporting_tap +if [ "$(daemon_restarts)" -eq 0 ]; then + ok "the daemon was never restarted (RestartCount=0)" +else + not_ok "the daemon restarted during the burst — see evidence" +fi +fget="$(vm_exec attacker "$CTL get $CTL_ARGS '$admin_token' >/dev/null 2>&1 && echo ok || echo fail")" +if [ "$fget" = ok ]; then + ok "the gRPC config path still answers after the burst (Get ok)" +else + not_ok "the gRPC Get failed after the burst — see evidence" +fi + +finish rt-4-8 "$XTCP2_EXPECT" From 3a8f41cc9cb4b3d0831c9a228c19d840e9cdb79f Mon Sep 17 00:00:00 2001 From: "randomizedcoder dave.seddon.ca@gmail.com" Date: Mon, 30 Nov 2026 03:21:21 -0800 Subject: [PATCH 2/6] =?UTF-8?q?fix(redteam):=20rt-11-5=20cycle=202=20?= =?UTF-8?q?=E2=80=94=20the=20backoff=20shape=20(a=20matrix-race=20assert?= =?UTF-8?q?=20race,=20not=20a=20product=20change)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 38-scenario full-matrix regression failed exactly one assertion (rt-11-5 ok 14, 'no new Write errors during the second stall'): cycle 2's fixed 18 s window demanded a Write-error rise, but cycle 1's error burst can leave the queue worker in a full-jitter backoff window where NO write is attempted, so nothing errors — measured: Write/error flat 9->9, dark the whole window (0 lines/6s), polls continuing 78->82, delivery healed on de-poison with no restart. Every MITIGATED verdict criterion held; the solo re-run errored 11->13 in-window. No product code changed since #361 (verified: destinations_tcp/queue untouched between df22997b2 and this branch). The fix, mirroring cycle 1's shape treatment: - Widen first: poll Write/error up to 60 s more while the poison is still active, so the deadline gets its best chance to show. - A third ok shape when the counter stays flat: the backoff shape, gated on the rest of the block's evidence — polls kept issuing (asserted in the same branch), and delivery heals on de-poison (ok 17) with no restart. The #345 freeze can do neither, so a flat Write/error with those two is provably the bounded backoff window, not a silent blind. A real freeze still fails ok 14 (polls frozen -> P2B == P2A -> not_ok) and ok 17 (no heal). Re-runs: 18/18 PASS (20261130T105600-d60b20007-3991909 — in-window errors, 11->13; 20261130T111556-d60b20007-4167647 — the fix on the branch head). --- vagrant/scenarios/rt-11-5-l2-delivery-kill.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/vagrant/scenarios/rt-11-5-l2-delivery-kill.sh b/vagrant/scenarios/rt-11-5-l2-delivery-kill.sh index 1e451d15e..d5eb4b783 100644 --- a/vagrant/scenarios/rt-11-5-l2-delivery-kill.sh +++ b/vagrant/scenarios/rt-11-5-l2-delivery-kill.sh @@ -222,6 +222,18 @@ W2A="$(tcp_write_err)" sleep 18 DARK2="$(catcher_delta_6s)" W2B="$(tcp_write_err)" +# Widen the error window before settling for a verdict: cycle 1's error +# burst can leave the queue worker in a full-jitter BACKOFF window, where +# no write is ATTEMPTED so nothing errors — poll for the counter while the +# poison is still active (measured race: matrix run 20261130T05xx, cycle 2 +# flat at 9->9 over the fixed 18 s window, dark the whole time, healed on +# de-poison — every verdict criterion held; the solo re-run errored 11->13 +# in-window). +for _ in $(seq 1 10); do + [ "$(tcp_write_err)" -gt "${W2A:-0}" ] && break + sleep 6 +done +W2B="$(tcp_write_err)" P2A="$(polls_issued)" sleep 8 P2B="$(polls_issued)" @@ -234,6 +246,12 @@ if [ "${W2B:-0}" -gt "${W2A:-0}" ] && [ "$DARK2" -le 10 ]; then ok "cycle 2: the same poison stalls delivery again and errors again (Write/error $W2A->$W2B, catcher $DARK2 lines/6s)" elif [ "${W2B:-0}" -gt "${W2A:-0}" ]; then ok "cycle 2: the second stall errors and self-heals again (Write/error $W2A->$W2B, catcher $DARK2 lines/6s — the broadcast-ARP race, cycle-1 shape B)" +elif [ "${P2B:-0}" -gt "${P2A:-0}" ]; then + # The backoff shape: polls kept issuing and (asserted next) delivery + # heals on de-poison with no restart — the #345 freeze cannot do either, + # so a flat Write/error here is the bounded backoff window, not a silent + # blind: no write was attempted, so nothing errored. + ok "cycle 2: the backoff shape — Write/error flat at $W2A (no write attempted: cycle 1's errors put the queue worker in full-jitter backoff), stall still bounded (polls $P2A->$P2B, de-poison heals next)" else not_ok "cycle 2: no new Write errors during the second stall — see evidence" fi From 9d11db7a03be35e895c13882ad8a913772bcd7dd Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Mon, 30 Nov 2026 09:35:41 -0800 Subject: [PATCH 3/6] =?UTF-8?q?fix(redteam):=20the=20PR=20#372=20review=20?= =?UTF-8?q?=E2=80=94=20four=20wrong-reason=20asserts,=20fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The review found four asserts that pass for the wrong reason or check something other than what they claim; no product code is at fault. 1. rt-11-8 msum always returned 0: the awk program sits inside a double-quoted string and carried \\ (escaped twice), so $1 expanded locally to the series substring — awk got a syntax error that '|| echo 0' then hid as a permanent 0. The add_rate and reconcile_incomplete checks could not fail; their zeros in run 1 were never measured. Fixed to \\'s single escape (rt-4-6's copy was correct); the helpers now document the trap. 2. rt-4-6 read the wrong series for reconcile/start: mval 'variable="start"' matches NINE series; sorted first is Deserialize/start (the envelope-deserialization counter, ~60/s — the quoted +14730 over the storm), NOT reconcile/start (~1/poll). Live-scrape confirmed: Deserialize/start 227550, reconcile/start 10828. Fixed to the full label set (function="reconcile",type="count",variable="start"); the reconcile-delta bound is now derived from the expected poll count, not the cycle count. #370's quoted number gets a correction comment. 3. The 'netns map drained' claim was wrong twice: each map entry holds a sockstat fd that KEEPS its namespace alive (sockstat.go:14-18), so a leaked entry keeps reading ~0 sockets — never 'unknown'; and -maxRecordsPerNetns is 262144 (1<<18), not 1M. The FD convergence check is the drain proof (a leaked entry = one leaked fd); the socket gauge now claims only 'no residual sockets'. Fixed in both churn scenarios + findings + plan + implementation. 4. rt-4-8's 'post-burst' sample was mid-burst: the poll-burst RPC returns immediately and SetPollFrequency does not stop a running burst (pollBurstRunner pokes on its own cadence for -count seconds), so the sample ~40-52 s in sat at the restored 2 s ticker + 1 s burst = 1.5 polls/s = 3x the 0.5/s baseline, exactly at the old 3x assert bound (flaky). Now waits for the daemon's own poke counter (pollBurstRunner poke+pokeDropped >= 120 — poke alone can stall when a poke is subsumed) before sampling, and the settle bound tightens to 2x. The mid-burst amplification attribution is corrected: ~half the 4.2x is the 1 s-floor ticker itself, half the burst (the daemon runs both). Also: the stores/dels=0 leg of the #370 check was a pass-on-bug — the 24 h variant sees the 6 h ticker fire and the day #370 lands the deltas become counted, so it is informational (two shapes) now, and 'duration-agnostic' no longer overclaims. rt-4-8's quota bounds derive from XTCP2_CPUS instead of hard-coding 2 CPUs / 210%. rt-11-5's comment cites the real matrix run ID (20261130T064858). All three churn scenarios register an EXIT trap so a set -e death tears down the drivers/sockfills instead of leaving them running on the VM (rt-4-8 restores the poll cadence). Gates: shellcheck + bash -n clean on all four; lint + lint-baseline re-run below with the re-verification. --- docs/redteam-implementation.md | 4 +- docs/redteam-plan.md | 6 +- vagrant/redteam/findings.md | 6 +- vagrant/scenarios/rt-11-5-l2-delivery-kill.sh | 2 +- vagrant/scenarios/rt-11-8-self-churn.sh | 46 ++++++---- vagrant/scenarios/rt-4-6-namespace-churn.sh | 87 ++++++++++++------- .../rt-4-8-poll-amplification-cpu-quota.sh | 78 ++++++++++++++--- 7 files changed, 160 insertions(+), 69 deletions(-) diff --git a/docs/redteam-implementation.md b/docs/redteam-implementation.md index 1b218c269..a3c3e1504 100644 --- a/docs/redteam-implementation.md +++ b/docs/redteam-implementation.md @@ -268,11 +268,11 @@ completing the RT-4 suite and RT-11 tiers 1–2. - [x] Phase 4 part 2 complete (the stream/gRPC suite): rt-4-3 **BLOCKED** (11/11 — read-cred oversize answered PermissionDenied at the method ACL before the 4 MB cap is even reachable; admin-cred oversize answered ResourceExhausted; a 10×20 reading storm cost a linear 299 goroutines, 1.1 M records, no leak 71→299→71), rt-11-3 **CONFIRMED** (11/11 — **the strongest RT-11 crossover**: ONE never-reading authenticated stream took the catcher 1993 → 0 lines/6 s; `flatRecordServiceSend`'s blocking per-client Send runs per record on the decode hot path, so one stalled stream backpressures the whole fleet; API stayed 200 — the tier-2 split; recovery ≤6 s, no leak), rt-4-4 **BLOCKED** (11/11 — RSS slope −17 KiB/s under 4 paced readers, and the backpressure finding: the catcher collapsed 1494 → 0 lines/6 s with EXACTLY 32 records in 240 s — the paced wedge, same root cause as rt-11-3), rt-2-9 **CONFIRMED** (7/7 — stream-expiry carry-over: 2158/2200 records flowed ~50 s past the skew-0 window; file-don't-fix, ops note: key rotation does not break held-open streams). New tool: grpcstorm (storm/oversize/wedge/paced/HMAC shapes, static, in the attacker tools tar); new deploy axis `XTCP2_PPROF` (a loopback, token-gated debug listener for goroutine-count asserts — an observability axis, not a surface change); rt-2-2's Phase-4 deferral landed as row rt-2-9. Full matrix regression: **30 scenarios, 29 PASS + 1 harness race fixed + re-verified solo** — rt-2-2's in-minute replay minted at :44 and the tcpdump window pushed the replay past the boundary (correct 401 under skew 0; the assert raced, not the product): the guard now lands the mint at 05..18 and re-mints once if a slow provision still crosses. - [x] Phase 4 part 3 complete (the delivery-outage suite): rt-4-7 **BLOCKED** (15/15, the split verdict — the s3 queue sink: RSS slope 70 KiB/s, the outage counted (`destS3Parquet/upload/error`, `s3_dropped_total=8`), recovery on endpoint return (objects 1270→2375); the tcp half: the permanent blind measured — counters light immediately, polling continues, the catcher restart changes nothing, only a daemon restart re-dials), rt-11-4 **BLOCKED** (14/14 — 300,008 thief sockets, victim coverage lag 0 s (parallel per-netns dumps + the 1 s poll-timeout valve), PollTimeout firing every cycle, RSS 29→31 MiB, and the amplifier at scale: 211,244 lines/6 s ≈ 100× baseline; the walkable budget engaged `xtcp_poll_degraded_total{level="sample"}` with victims still at 0 s lag), rt-11-5 **CONFIRMED** (16/16 — the L2 freeze: a CAP_NET_RAW sibling ARP-blackholes the sink via a 200 ms gratuitous-reply loop; the poller FREEZES in the blocked Write (no deadline, sync on the poll goroutine) for the whole retransmit window (~15.4 min at the prod default) with zero error counters and scrape 200; de-poison mid-window = full catch-up with no loss; the window closed = counters light + delivery permanently dead). New tool: arppoison (static, in the attacker tools tar); new deploy axes `XTCP2_MAX_RECORDS` (rt-11-4's walkable budget) and `XTCP2_SINK_IP` (rt-11-5's dedicated sink alias — poisoning the gateway takes the docker-proxy replies down with it, measured); the freeze finding filed as #345. Full matrix regression: **33 scenarios, 32 PASS + 1 tool race fixed + re-verified solo** — rt-4-3's oversize probe (leg B) raced the transport's arrival-based recv-limit kill against a fanned-out record beating the 8 MB frame on a fresh slow-start conn (measured OK 3/3 in the matrix, ResourceExhausted 12/12 by hand): the probe now drains Recv to the terminal verdict. - [x] **Product fixes #345 + #339 landed with the expectation flips in the same change** (the S2 pair the delivery-outage suite surfaced): the tcp destination is now a bounded queue + worker — `Send` never blocks (the poller can never freeze on the sink), every write AND dial carries `tcp_write_timeout` (config field 120, validate-gted/lte'd to [1s, 1h], Go belt `resolveTCPWriteTimeout`, default 30 s, CLI `-tcpWriteTimeout`/`TCP_WRITE_TIMEOUT` env), the queue is `envelopeQueue` shared with s3 (moved untagged to destinations_queue.go — tcp is in every flavor including stdlib-only), and a failed write reconnects under full-jitter backoff (the `backoffWindow` cap derived like s3's: clamp(poll_frequency/10, 1s, 1h)) with 3 attempts per envelope, then drop-and-count. New counters: `xtcp_tcp_dropped_total{reason}` / `_bytes_total` / `xtcp_tcp_buffered_bytes{stage}` + `destTCP` Dial/Reconnect/queueFull/dropped. Verified by the same attacks that pinned the bugs: **rt-11-5 MITIGATED 18/18** (polls keep issuing through the stall 25→47/32 s — the freeze gone; Write/error=9, Dial/error=8, drops=3 while dark; de-poison heals with NO restart, reconnects=1; second cycle repeats — a REACHABLE neighbor entry ignores gratuitous ARP until STALE ~30 s, the flip is now a bounded wait) and **rt-4-7 BLOCKED 15/15** (the catcher restart heals delivery, reconnects=1, 2482 lines/6 s — no daemon restart). Harness: deploy axis `XTCP2_TCP_WRITE_TIMEOUT` (Vagrantfile arg 12). Harness lesson: `promLabels` order is function, VARIABLE, type — `WithLabelValues("destTCP","Write","error")` emits `type="error",variable="Write"`; grep the emitted order or the assert reads empty. Post-merge regression: **33/33 on main `14d7e1c38c` (PR #352)** — the first full-matrix sweep hit an environmental cascade (unattended-upgrades grabbed the dpkg frontend lock at scenario 24 — the last five scenarios failed provisioning in a row; `common.sh` now stops/masks the apt-daily timers and waits out an in-flight run, re-verified across all 33 provisions), and rt-11-5's dark window needed the two-shape accept: the write deadline can let a re-dial's broadcast ARP beat the poison — delivery SELF-HEALS mid-attack (1262 lines/6 s, drops=0, evidence `20261127T065504-195d45c15-839055`) — a stronger mitigation than the sustained stall the assert had pinned as the only valid shape (re-verified 18/18 MITIGATED shape-A, `20261127T071651-195d45c15-986471`). -- [ ] 24 h churn variant runs clean overnight once (logged evidence), or its blocker filed. (Phase 4 part 4 — the variant is built and env-gated: `RT_CHURN_SECS=86400 nix run .#redteam-rt-4-6`; all asserts duration-agnostic; the overnight run itself is outstanding) +- [ ] 24 h churn variant runs clean overnight once (logged evidence), or its blocker filed. (Phase 4 part 4 — the variant is built and env-gated: `RT_CHURN_SECS=86400 nix run .#redteam-rt-4-6`; the asserts are ratio/bound-based, and the stores/dels observability check is informational — a 24 h window SEES the 6 h ticker fire, which is not a failure; the overnight run itself is outstanding) - [x] rt-11-5 shows delivery metrics lighting up during the L2 kill (assert specific series non-zero), or files the observability gap. (landed with the #345/#339 fix: the scenario asserts `destTCP` Write/Dial errors ≥1 while dark and — shape A — `xtcp_tcp_dropped_total` ≥1; the silent window is now counted, verified both cycles) - [x] Phase 4 part 4 (conntrack leg): rt-11-6 **BLOCKED** (17/17, shape A `20261128T031048-c0f904e3d-3955865`; shape B 16/16 `20261127T232913-b7769a466-1209893`): the spray cannot stop reporting — established delivery immune, the re-dial races the slot leak and the #352 queue bounds the loss (both shapes green), no restart, polls never stop. The measured crossover is the ops view: a fresh scrape via docker-proxy needs a conntrack entry, so /metrics goes 000 while records flow — "absence of metrics must itself alert" confirmed end-to-end; harness lessons (mgmt-/24 NOTRACK, pgrep self-match, session-hold hang) encoded in-scenario. - [x] rt-11-7 **survives** (18/18, `20261129T091855-df22997b2-1827895`): a NET_ADMIN co-tenant builds pathological-but-legal own-netns state on the new locality deploy axis (`XTCP2_ENRICH=locality` — a rtnetlink listener inside every discovered netns); 87 links / 976 corpus neighbors / 1012 routes at the kernel's own extremes (15-char names, 255-char labels, metric 0/4294967295, 32-nexthop multipath, v6 zero-MAC), the listener parsed **+1141 corpus events live** and a forced ROUTE event re-dumped the full corpus (snapshot periodic 1→2) — no panic, no restart, scrape 200, catcher grew through the build. No fixture needed. Measured coverage finding: localityGroups excludes GroupNeigh — the deployed daemon never reads neighbor tables; the plan's "huge neighbor tables" leg was NOT exercised — the pathological-MAC corpus is kernel-resident only (a fixture seed for the day the enricher reads neighbors). Harness: dpkg-lock-era VM disk full (catcher 5.8 G + docker json logs 8.1 G) fixed at the source — common.sh truncates both at provisioning; xtcp2_deploy truncates BEFORE the tarball scp (a full disk killed the delivery itself); tcp-stress NUL-byte stdout capped (`--log-opt max-size`) — the work containers had filled 4.0 G each. -- [x] **Phase 4 part 4 complete (the churn/cgroup suite)**: rt-4-6 **BLOCKED** (16/16, `20261130T041837-848ebbe00-1287288` — 149 netns add+del cycles in 240 s, poll_sockets 237→7875, CPU 111–114% of 4 vCPUs, victim flowing MID-storm, `reconcile_incomplete` 0→0; post-storm convergence go_goroutines 51→51 / FDs 53→53 / poll_sockets 245 — no leak, no map leak; **finding #370: netns add/del is invisible in metrics**, the per-poll reconcile drops its deltas, mapReconciler's stores/dels only fire on the 6 h ticker), rt-11-8 **BLOCKED** (18/18, `20261130T042718-848ebbe00-1464077` — 20 `docker restart` cycles each re-packing 10000 sockfill pairs (poll_sockets 241→20244): mid-storm victim lag 0 s, reconcile p99 0.00032 s, `add_rate`=0, no leak — self-churn does not even register), rt-4-8 **BLOCKED** (16/16, `20261130T045657-848ebbe00-1525702` — the refocused cgroup-cap variant, XTCP2_CPUS=2: an admin TriggerPollBurst 120×1 s multiplies records 116→491 rec/s while CPU stays 130.9%/132.0% vs the 210% quota bound, RSS 24453→27002 kB, no OOM, metrics answers, rate settles post-burst; the nuance: the burst multiplies RECORDS not CPU — the record-volume residual is #342's family; prod guidance: pin XTCP2_CPUS). The 24 h churn variant is env-gated (`RT_CHURN_SECS=86400 nix run .#redteam-rt-4-6`, never a matrix default) — all asserts duration-agnostic. +- [x] **Phase 4 part 4 complete (the churn/cgroup suite)**: rt-4-6 **BLOCKED** (16/16, `20261130T041837-848ebbe00-1287288` — 149 netns add+del cycles in 240 s, poll_sockets 237→7875, CPU 111–114% of 4 vCPUs, victim flowing MID-storm, `reconcile_incomplete` 0→0; post-storm convergence go_goroutines 51→51 / FDs 53→53 / poll_sockets 245 — no leak; **finding #370: netns add/del is invisible in metrics**, the per-poll reconcile drops its deltas, mapReconciler's stores/dels only fire on the 6 h ticker — measured via `reconcile/start` ~1/poll, not the run's original +14730 figure, which was the Deserialize/start series read through an ambiguous `variable="start"` match), rt-11-8 **BLOCKED** (18/18, `20261130T042718-848ebbe00-1464077` — 20 `docker restart` cycles each re-packing 10000 sockfill pairs (poll_sockets 241→20244): mid-storm victim lag 0 s, reconcile p99 0.00032 s, `add_rate`=0, no leak — self-churn does not even register; review correction: run 1's `add_rate`/`reconcile_incomplete` zeros were read through a broken msum — the awk `$1` escaped twice expanded locally to the series name, the syntax error hidden by `|| echo 0` — the fixed helper re-measures them), rt-4-8 **BLOCKED** (16/16, `20261130T045657-848ebbe00-1525702` — the refocused cgroup-cap variant, XTCP2_CPUS=2, both quota bounds derived from it: an admin TriggerPollBurst 120×1 s multiplies records 116→491 rec/s (~half the 1 s-floor ticker, half the burst — the total forced cadence) while CPU stays 130.9%/132.0% vs the 210% quota bound, RSS 24453→27002 kB, no OOM, metrics answers, rate settles once the poke counter proves burst completion (run 1 sampled mid-burst at ~3× the baseline, right at the old bound); the nuance: the forced cadence multiplies RECORDS not CPU — the record-volume residual is #342's family; prod guidance: pin XTCP2_CPUS). All three reviewed and fixed (the review caught four wrong-reason asserts; re-verified solo). The 24 h churn variant is env-gated (`RT_CHURN_SECS=86400 nix run .#redteam-rt-4-6`, never a matrix default) — the asserts are ratio/bound-based, the stores/dels check informational. - [x] **Task 4.11 wrap-up (the observability enabler)**: of the four gauges the suite needs, three already exist and are now asserted in-scenario — FD usage (`process_open_fds`, the standard collector), goroutines (`go_goroutines`), poll-cycle duration (`Poller/pollToDoneDuration` + `PollTimeout`), delivery errors (`destTCP/Write/error`, `destS3Parquet/upload/error`, `Poller/envelopeFlush/error`); per-namespace coverage lag does NOT exist (aggregate-only) — filed as **#371**; the NEW measured gap — netns churn invisibility — filed as **#370** (the per-poll reconcile's add/del deltas are dropped). - [ ] Every scenario traps cleanup; a final "victim still reporting" assertion runs after each attack (the RT-11 invariant). - [ ] The wire-the-limits issue (max_connections/accept-rate) has measured evidence attached. diff --git a/docs/redteam-plan.md b/docs/redteam-plan.md index ee7a70012..e00f48c2b 100644 --- a/docs/redteam-plan.md +++ b/docs/redteam-plan.md @@ -181,9 +181,9 @@ left auth disabled. These test what admin access is worth. | rt-4-3 | gRPC stream abuse | h2load/ghz: many conns × 20 streams, 4 MB messages, reflection flood | per-conn stream cap 20, 4 MB message limit; no global quota | **VERIFIED 2026-11-25 (BLOCKED — all three legs land inside the guards)**: read-cred oversized `PollFlatRecords` → PermissionDenied ×3 (the method ACL answers BEFORE the recv cap — `PollFlatRecords` is admin-served, so a read credential never reaches the size check and cannot even enumerate the method); admin-cred oversized → ResourceExhausted ×3 (MaxRecvMsgSize=4MB answers); the reading storm (10 conns × 20 streams × 100 rec/s, 60 s) → goroutines 71→299 (linear, ~1/stream + ~5/conn), scrape 200, catcher flowing, 1.1 M records delivered, no leak after (71→299→71). Unauthenticated reflection is the rt-1-2 shape (same StreamServerInterceptor) | bounded degradation only; assert no goroutine leak after close (metrics//`/debug` after test — or pprof via loopback) | S3 | | rt-4-4 | Slow FlatRecords consumer | open authenticated stream, read 1 msg/30 s, never cancel | gRPC flow control should backpressure the daemon pipeline | **VERIFIED 2026-11-25 (BLOCKED on the OOM axis — and the backpressure is the finding)**: 4 paced readers (1 msg/30 s) for 240 s — RSS slope −17 KiB/s (29 MiB flat; envelope row/byte caps + record pool hold), daemon alive. But sink delivery COLLAPSED to the readers' pace: catcher 1494 → **0 lines/6 s** while held, and exactly 32 records crossed in 240 s — the 4 × 8 paced reads, no more. `flatRecordServiceSend`'s blocking per-client Send runs on the record hot path, so the whole pipeline (envelope flush included) is coupled to the slowest reader: the rt-11-3 wedge, paced. 1 h soak via `RT_SOAK=1h` (env-gated, not in the matrix) | daemon memory bounded under stalled consumers for 1 h; no OOM; record the envelope-buffer high-water mark | S3 | | rt-4-5 | Scrape storm | 100 parallel scrapes of `/metrics`, `/metrics-all`, detail paths | 10 in-flight cap on main path; category caps 4; 10 s handler timeouts | **VERIFIED 2026-11-25 (BLOCKED)**: the fast path self-throttles (100x 200, p99 11 ms — the ~17 ms body answers faster than staggered curls stack 10-deep) and the cap engages where a pileup could form: `/metrics-all` 10x 503, `/metrics/link` 3x 503, zero failed conns, no pileup (clean scrape 1.9 ms after), healthz 200, catcher flowing throughout | 503/queue behavior matches docs; no pileup; p99 latency recorded | S4 | -| rt-4-6 | Namespace/socket churn storm | run `nsTest` + a script creating/destroying netns and 10k sockets rapidly in co-tenant containers visible to the daemon | reconcile before each poll; retry loops for vanished veths | **VERIFIED 2026-11-30 (BLOCKED — the storm loses on every axis)**: 149 netns add+del cycles in 240 s (one launch/s, each container 2500 LISTEN + 2500 client sockets, dead ~2.5 s, `--rm`): poll_sockets 237→7875 mid-storm, CPU 111–114% of 4 vCPUs, victim records flowing MID-storm, `reconcile_incomplete_total` 0→0; post-storm convergence **go_goroutines 51→51, process_open_fds 53→53, poll_sockets 245** (a leaked dead netns would count 1M unknown sockets in the gauge) — no fd leak, no goroutine leak, no restart, 16/16 (`20261130T041837-848ebbe00-1287288`). **Finding #370: netns add/del is invisible in metrics — mapReconciler stores/dels only fire on the 6 h ticker; the per-poll reconcile (the ACTUAL discovery path) returns its deltas uncounted.** The 24 h variant is env-gated (`RT_CHURN_SECS=86400`), never a matrix default | no fd leak, no goroutine leak, bounded CPU, daemon survives 24 h churn (ties into TODO-SOON AI098) | S2 | +| rt-4-6 | Namespace/socket churn storm | run `nsTest` + a script creating/destroying netns and 10k sockets rapidly in co-tenant containers visible to the daemon | reconcile before each poll; retry loops for vanished veths | **VERIFIED 2026-11-30 (BLOCKED — the storm loses on every axis)**: 149 netns add+del cycles in 240 s (one launch/s, each container 2500 LISTEN + 2500 client sockets, dead ~2.5 s, `--rm`): poll_sockets 237→7875 mid-storm, CPU 111–114% of 4 vCPUs, victim records flowing MID-storm, `reconcile_incomplete_total` 0→0; post-storm convergence **go_goroutines 51→51, process_open_fds 53→53, poll_sockets 245** — the FD convergence is the netns-drain proof (each map entry holds one sockstat fd; a leaked entry = one leaked fd; the socket gauge alone cannot discriminate — a leaked entry keeps its namespace alive and reads ~0 sockets, never "unknown"; −maxRecordsPerNetns is 262144, not 1M) — no fd leak, no goroutine leak, no restart, 16/16 (`20261130T041837-848ebbe00-1287288`; re-verified after the review's exact-series fix). **Finding #370: netns add/del is invisible in metrics — mapReconciler stores/dels only fire on the 6 h ticker; the per-poll reconcile (the ACTUAL discovery path) returns its deltas uncounted** (measured via `reconcile/start` ~1/poll — the run's original +14730 figure was Deserialize/start, the wrong series). The 24 h variant is env-gated (`RT_CHURN_SECS=86400`), never a matrix default | no fd leak, no goroutine leak, bounded CPU, daemon survives 24 h churn (ties into TODO-SOON AI098) | S2 | | rt-4-7 | Broker-outage buffering | kill the in-VM Redpanda; watch daemon | franz-go backoff with jitter (design doc) | **VERIFIED 2026-11-26 (BLOCKED on the queue sink — split verdict, both halves measured)**: half 2 (s3parquet→Garage, the queue-shaped sink): daemon memory bounded while the sink is down (RSS slope 70 KiB/s; queue depth 16 / 64 MiB, oldest-first eviction), the outage is VISIBLE and COUNTED (`destS3Parquet/upload/error=1` after the backoff, `s3_dropped_total=8`), and minio dials per request so the daemon RECOVERS on endpoint return (objects 1270 → 2375) — the plan's expectation holds. Half 1 (tcp, the catcher): the Write errors immediately on the dead conn (FIN/RST — no stall), the counters light up, polling continues — but the blind is **PERMANENT**: a catcher restart changes nothing (0 lines/6 s with the catcher back; tcpDest never reconnects, #339), only a daemon restart re-dials (measured). The permanent-blind finding is asserted in-row and filed under #339. **FIXED same day (#339 landed with this expectation flip)**: the tcp destination is now a bounded queue + worker — Send never blocks, every write and dial carries `tcp_write_timeout`, a failed write reconnects under full-jitter backoff. Re-verified **BLOCKED 15/15** (evidence `20261126T110001-209ab068a-1548426`): the outage is counted (`destTCP` Write/error=24, Dial/error=25, `xtcp_tcp_dropped_total=9`), polls continue, and **the catcher restart heals delivery with NO daemon restart** (reconnects=1, 2482 lines/6 s after return) — the plan's expectation now holds on BOTH halves | memory bounded while dest is down; recovers on broker return; no unbounded queue | S3 | -| rt-4-8 | Admin-triggered poll amplification | (needs admin) poll burst against a host with 100 containers × 250 sockets | full-dump per poll | **VERIFIED 2026-11-30 (BLOCKED — the quota holds the line)**: the refocused cgroup-cap variant (the XTCP2_CPUS deploy axis, pinned 2; the 100-container population was premortem-refocused as arithmetic — rt-3-3 measured the mechanism). The admin sets the 1 s floor and runs TriggerPollBurst 120×1 s under the quota: record rate 116→491 rec/s (**4.2×**), daemon CPU **130.9%/132.0%** vs 116% baseline — inside the quota bound, RSS 24453→27002 kB, no OOM-kill, metrics answers through the burst, rate settles post-burst, no restart, 16/16 (`20261130T045657-848ebbe00-1525702`). The nuance: at this population the burst multiplies RECORDS not CPU (116→131% for 4.2× records — polling is cheap); the record-volume residual is #342's family (the burst's `-count` bounds it). Prod guidance: pin XTCP2_CPUS — the default deploy is unlimited | latency/CPU bounded; assert cgroup protection works | S3 | +| rt-4-8 | Admin-triggered poll amplification | (needs admin) poll burst against a host with 100 containers × 250 sockets | full-dump per poll | **VERIFIED 2026-11-30 (BLOCKED — the quota holds the line)**: the refocused cgroup-cap variant (the XTCP2_CPUS deploy axis, pinned 2, both quota bounds worked out from it; the 100-container population was premortem-refocused as arithmetic — rt-3-3 measured the mechanism). The admin sets the 1 s floor and runs TriggerPollBurst 120×1 s under the quota: record rate 116→491 rec/s (**4.2× — the TOTAL forced cadence: ~half the 1 s-floor ticker, half the burst stacked on top**), daemon CPU **130.9%/132.0%** vs 116% baseline — inside the quota bound, RSS 24453→27002 kB, no OOM-kill, metrics answers through the burst, rate settles post-burst (sampled only after the poke counter proves burst completion — the run-1 "post-burst" sample ~40 s in sat mid-burst), no restart, 16/16 (`20261130T045657-848ebbe00-1525702`; re-verified after the review's burst-completion fix). The nuance: at this population the forced cadence multiplies RECORDS not CPU (116→131% for 4.2× records — polling is cheap); the record-volume residual is #342's family (the burst's `-count` bounds it). Prod guidance: pin XTCP2_CPUS — the default deploy is unlimited | latency/CPU bounded; assert cgroup protection works | S3 | ### RT-5 Host attacks through xtcp2 (netlink and capabilities) @@ -278,7 +278,7 @@ listeners; true with `--network host` or published ports): | rt-11-5 | L2 kill of the delivery path | if the destination (Kafka/Redpanda, S3 endpoint container) is a sibling on the same bridge, both endpoints are on-path to each other: spoofed RSTs or ARP blackholing of the daemon→broker TCP. franz-go retries with jitter forever, so the daemon looks healthy while delivering nothing | jittered backoff (fleet design); reconnect | **VERIFIED 2026-11-26 (CONFIRMED — stronger than the premise: an L2 stall does not just blind delivery, it freezes COLLECTION)**: a privileged co-tenant (CAP_NET_RAW, sibling on the bridge — a dedicated docker0 alias keeps the gateway path clean so the API stays 200) ARP-blackholed the sink with a 200 ms gratuitous-reply loop (arppoison; existing entries flip with default arp_accept). Measured timeline: delivery dies instantly (0 lines/6 s); the Writes keep SUCCEEDING locally while SO_SNDBUF absorbs envelopes; the buffer fills → the Write blocks → **the whole poller freezes** (polls frozen 14 s at tcp_retries2=8; ~15.4 min at the prod default retries2=15) with **zero error counters** and scrape 200 — fully silent. De-poison mid-window: the buffered envelopes drain, the catcher catches up (1667 lines/6 s), no error counters, **no loss** — the blind is latency, not loss. The window closed (retries2=3): counters light up only then (the row's visibility premise holds, after the gap), polls resume, and delivery is permanently dead until a daemon restart (no reconnect, #339). **Product finding filed (#345)**: SetWriteDeadline + decouple the flush from the poll goroutine. **FIXED same day (#345 + #339 landed with this expectation flip)**: the tcp destination queues to a bounded worker (`Send` never blocks the poller), every write and dial carries `tcp_write_timeout` (default 30 s, deploy axis `XTCP2_TCP_WRITE_TIMEOUT`; this run pins 5 s), and a failed write reconnects under full-jitter backoff. Re-verified **MITIGATED 18/18** (evidence `20261126T111738-209ab068a-1688938`, two full poison cycles): polls keep issuing through the stall (25→47 over 32 s — the freeze is gone), the blind is VISIBLE and COUNTED while dark (Write/error=9, Dial/error=8, `xtcp_tcp_dropped_total=3`, scrape 200), de-poison heals delivery with NO daemon restart (reconnects=1, 2498 lines/6 s), and the second cycle repeats the whole arc (Write/error 10→14, polls 77→82, heals again at 2500 lines/6 s). The residual — delivery still stalls while the route is blackholed — is physics, bounded by the deadline and visible in the counters | assert delivery-failure counters/metrics make the blind *visible* (`xtcp_counts` delivery errors, `xtcp_gauges` delivery health); finding: sustained L2 kill = silent-ish outage without an external watchdog | S2 (fixed) | | rt-11-6 | Host noisy-neighbor starvation | CPU fork bomb without cpu quota, memory pressure toward OOM (xtcp2 has real RSS), **conntrack-table exhaustion** (mass short-lived flows through host NAT → `nf_conntrack: table full` drops the daemon's outbound SYN to Kafka/S3), pid-limit exhaustion breaking the `/proc` walk | container cgroup limits are deployment policy | **VERIFIED 2026-11-28 (BLOCKED — the spray loses; the ops view doesn't)**: the conntrack leg, measured twice (shape B `20261127T232913-…` 16/16; shape A `20261128T031048-…` 17/17). A plain-tier co-tenant spraying ~700 conns/s through docker0 (sockfill -spray: dial, close cleanly — each conn lingers ~120 s as a TIME_WAIT conntrack entry) pins the host netns table in ~20 s against the harness pin of 12288 (stock 262144 needs >2200/s sustained — a fleet, not a myth); dmesg ×1275. Established delivery is immune (49559 lines/6 s with the table full). A forced re-dial against the full table is a race: shape B healed THROUGH the storm (the spray's own TIME_WAIT expiry frees ~max/120 slots/s — 58027 lines/6 s, one counted Dial error); shape A went dark until the drain and the #352 queue bounded it (Dial/error=1, dropped=27, reconnects=1, no restart, polls +64 throughout). The row's real finding: **a fresh scrape through docker-proxy needs a new conntrack entry for the proxy's backend leg, so /metrics times out (000) while records keep flowing** — the monitoring path is the casualty, not collection; heals with the table. "Absence of metrics must itself alert" confirmed end-to-end: during the storm the fleet's own scrape IS the absent metric. | assert per-link effects and that each has a metric the fleet can alert on; finding: "absence of metrics must itself alert" — an external liveness watchdog is a deployment requirement | S2 (finding: the scrape-path blind) | | rt-11-7 | Own-netns parser crash attempt | pathological own netns (max-length ifnames, huge neighbor/route tables, nested veth/macvlan) hoping for a typed-parser panic; a panic in the poll path takes the whole daemon (the link-monitor panic-isolation issue is documented as open) | fixture-tested parsers, fuzz targets | **VERIFIED 2026-11-29 (BLOCKED — the corpus loses; the daemon does not flinch)**: a NET_ADMIN co-tenant builds pathological-but-legal own-netns state — 87 links (15-char IFNAMSIZ-1 names, 255-char ifalias labels, macvlan, vlan 4094, veth-under-bridge), 976 corpus neighbors (all five pathological MAC shapes; `ip neigh` prints 977 with the container's own gateway line), 1012 routes (metrics 0 and 4294967295, a 32-nexthop multipath, v6 zero-MAC fe80::1), fib rules at pref 4294967294/4294967295 — on the new locality deploy axis (`-enrichLocality -localityEvents`), so a rtnetlink listener runs INSIDE the attacker's netns. The attacker cannot send bytes: the kernel serializes the state into well-formed netlink and every message flows through the parsers. Measured: the listener parsed **+1141 corpus events live** through the build (events 108→1249); one forced ROUTE event after the 60 s quiet window fired a full re-dump (snapshot periodic 1→2 — the whole corpus re-parsed through the dump path); through all of it no panic, no restart, scrape 200, catcher grew through the build — a parser panic anywhere takes the daemon (no recover() in the listener path), none tripped. **Measured coverage gap (finding, not a crash): localityGroups excludes GroupNeigh — the deployed daemon never dumps or subscribes to neighbors; the plan's "huge neighbor tables" leg was NOT exercised — the pathological-MAC neighbor corpus is kernel-resident only, a fixture seed for the day the enricher reads neighbors** | daemon survives; any crash = S1-class finding feeding the fixture corpus | -| rt-11-8 | Self-churn + reconcile amplification | rapid own socket churn and `docker restart` loops make discovery/dockermeta/reconcile (which runs before each poll) burn the cycle; AI098 warn-storm | churn handling, retry logic | **VERIFIED 2026-11-30 (BLOCKED — self-churn does not even register)**: 20 `docker restart -t 0 rt-attacker` cycles ~4.5 s apart, each re-packing 10000 sockfill loopback pairs (poll_sockets 241→20244): mid-storm victim coverage lag **0 s** (the row's verdict criterion), reconcile `complete` p99 **0.00032 s** (the 1 s budget is 3000× above), victim records flowing mid-storm, post-storm go_goroutines 51→51 / FDs 53→53 / poll_sockets 250 (map drained), `add_rate`=0, `reconcile_incomplete`=0, no restart, 18/18 (`20261130T042718-848ebbe00-1464077`). The rt-4-6 observability finding (#370) applies verbatim: stores/dels stay 0 in this shape | bounded reconcile cost; no coverage lag on victim namespaces | +| rt-11-8 | Self-churn + reconcile amplification | rapid own socket churn and `docker restart` loops make discovery/dockermeta/reconcile (which runs before each poll) burn the cycle; AI098 warn-storm | churn handling, retry logic | **VERIFIED 2026-11-30 (BLOCKED — self-churn does not even register)**: 20 `docker restart -t 0 rt-attacker` cycles ~4.5 s apart, each re-packing 10000 sockfill loopback pairs (poll_sockets 241→20244): mid-storm victim coverage lag **0 s** (the row's verdict criterion), reconcile `complete` p99 **0.00032 s** (the 1 s budget is 3000× above), victim records flowing mid-storm, post-storm go_goroutines 51→51 / FDs 53→53 / poll_sockets 250 (the FD convergence is the drain proof), `add_rate`=0, `reconcile_incomplete`=0 (run 1's zeros for these two were read through a broken helper — the awk `$1` escaped twice expanded locally, the syntax error hidden as a permanent 0; re-measured with the fix), no restart, 18/18 (`20261130T042718-848ebbe00-1464077`; re-verified after the review's msum fix). The rt-4-6 observability finding (#370) applies verbatim: stores/dels stay 0 in this shape | bounded reconcile cost; no coverage lag on victim namespaces | **Tier 2 — co-tenant holding only a read credential:** rt-11-1/2/3 still apply unchanged (FDs and stream slots are consumed before authorization, and diff --git a/vagrant/redteam/findings.md b/vagrant/redteam/findings.md index a041ed160..a3a890a10 100644 --- a/vagrant/redteam/findings.md +++ b/vagrant/redteam/findings.md @@ -69,9 +69,9 @@ that gets fixed flips its `EXPECT` in the same PR as the fix | rt-11-6 | 2026-11-28 | bridge+raw+plain, SINK_IP=172.17.99.2 (conntrack leg) | BLOCKED | S2 (finding: the scrape-path blind) | `20261128T031048-c0f904e3d-3955865` (shape A), `20261127T232913-b7769a466-1209893` (shape B) | **The conntrack spray cannot stop xtcp2 reporting — but it CAN blind the ops view.** A plain-tier co-tenant (no caps; sockfill -spray, ~700 conns/s — dial, close cleanly, each conn lingers ~120 s as a TIME_WAIT conntrack entry; the harness pins nf_conntrack_max=12288 as time compression — stock 262144 needs >2200/s sustained, i.e. a noisy-neighbor fleet) pins the HOST netns table in ~20 s; dmesg logs `nf_conntrack: table full` ×1275. Measured effects: (1) **established delivery is immune** — 49559 lines/6 s with the table full (its entry is already allocated); (2) a re-dial against the full table is a RACE the daemon usually wins (the storm's own TIME_WAIT expiry frees ~max/120 slots/s): shape B healed THROUGH the storm (58027 lines/6 s mid-storm, one counted Dial error); shape A went dark until the drain and the #352 queue bounded it (Dial/error=1, dropped=27, reconnects=1, delivery healed with NO restart, polls +64 throughout). The two-shape assert accepts both; the only failure is a silent stall. (3) **The real blind: a fresh scrape through docker-proxy needs a new conntrack entry for the proxy's backend leg, so /metrics times out (000) while records keep flowing** — the daemon is fine, the monitoring path is the casualty; heals with the table (401). "Absence of metrics must itself alert" confirmed end-to-end: during the storm the fleet's scrape IS the absent metric. Harness lessons (encoded in-scenario): the vagrant control path is the DHCP mgmt net **192.168.121.0/24, NOT the private /24** — NOTRACK mgmt+private+lo or the storm stalls the scenario's own ssh on SYN retransmits and starves the next provisioning's DNS-over-ens6; a mid-run death MUST reset the pin (defensive ct_reset + EXIT trap) or every following scenario starves; `pgrep -f` matches its own cmdline (listener never started — spray ok=0 for 85 K attempts) and `A || B &` hangs the ssh session (the subshell holds stdout waiting on socat) — check with ss, start bare. | | rt-11-7 | 2026-11-29 | bridge+raw+plain, ENRICH=locality (the -enrichLocality -localityEvents axis) | BLOCKED | none | `20261129T091855-df22997b2-1827895` (18/18) | **The parser corpus loses; the daemon does not even flinch.** A NET_ADMIN co-tenant builds pathological-but-legal own-netns state (all probe-verified kernel-accepted): 87 links (veth pairs with 15-char IFNAMSIZ-1 names, 255-char ifalias labels, macvlan + vlan id 4094 on a veth, a veth enslaved to a bridge), 976 corpus neighbors (39 veths × 25 cycling all five pathological MAC shapes — zero, broadcast, IPv4-mcast 01:00:5e:ff:ff:ff, IPv6-mcast 33:33:…, locally-administered 02:00:… — plus the v6 zero-MAC fe80::1; `ip neigh` prints 977 lines, the +1 being the container's own eth0 gateway), 1012 routes (metrics 0 and 4294967295 — the u32 extremes, a 32-nexthop multipath route, v6 zero-MAC fe80::1 + metric-max /128), fib rules at pref 4294967294/4294967295. The attacker cannot send bytes: the kernel serializes the state into well-formed netlink and the daemon parses it via the per-netns locality listener (deployed on the new locality axis; a fresh container's listener starts within 5 s, probe-verified). Measured: **the listener parsed +1141 corpus events live through the build** (localityListener events 108→1249), a forced ROUTE event after the 60 s quiet window fired a full re-dump (snapshot periodic 1→2 — the whole corpus re-parsed through the dump path), and through all of it: no panic, no restart, scrape 200, the catcher grew through the build (8503→8984 lines/6 s). A parser panic anywhere takes the whole daemon (no recover() in the listener path) — none tripped. **Measured coverage gap (finding, not a crash): localityGroups (pkg/xtcp/enrich_locality_listen.go) excludes GroupNeigh — "Neighbors are not one" — so the deployed daemon never dumps or subscribes to neighbor tables at all; the plan's "huge neighbor tables" leg was NOT exercised — the 976 pathological-MAC neighbors are kernel-resident only** (they seed a fixture corpus for the day the enricher starts reading neighbors). Harness lessons (encoded): 16-char ifnames are kernel-rejected ("Attribute failed policy validation" — IFNAMSIZ enforced); routes on DOWN veths are rejected ("Device for nexthop is not up" — bring links up first); a neigh-replace forced event is INVISIBLE to the listener (probe: events flat at a neigh event, +1 periodic/rebuilds at a route one — force ROUTE events); POSIX sh (dash) rejects `${n/a/b}` — derive peer names with printf; `wait_for` returns 1 on timeout and set -e kills the scenario before its RESULT line — guard with `|| true`; the emitted label order is function,TYPE,variable (read the raw series, and fold absent series to 0). | -| rt-4-6 | 2026-11-30 | bridge+raw+plain, host-side churn driver (stated vantage: the fleet-operator position — a PLAIN attacker cannot create netns; NET_ADMIN does not grant it either, the rt-11-7 ladder) | BLOCKED | S4 (observability, #370) | `20261130T041837-848ebbe00-1287288` (16/16) | **The churn storm loses on every axis.** 149 netns add+del cycles in 240 s (one launch/s, each container: tcp-stress `both` with `-close` — 2500 LISTEN + 2500 client sockets, dead ~2.5 s, `--rm`): poll_sockets 237→7875 mid-storm, daemon CPU 111–114% (of 4 vCPUs; bound 250%), victim records flowing MID-storm, `reconcile_incomplete_total` 0→0 (the 1 s scan budget never tripped). Post-storm convergence (measured: in-flight goroutines take ~2 min to drain — run 1's +15 at 30 s settled to baseline−1 by 4 min, flat — convergence waits, not fixed sleeps): **go_goroutines 51→51, process_open_fds 53→53, poll_sockets back to 245** (a leaked dead netns counts as unknown = −maxRecordsPerNetns = 1M sockets in the gauge, so baseline-level = the map drained). No FD leak, no goroutine leak, no restart. **Finding (#370): the row's core mechanism — netns add/del under churn — is invisible in metrics**: `mapReconciler` stores/dels only fire on the 6 h background ticker (never in a 4-min run), and the per-poll reconcile (the ACTUAL discovery path, `reconcileBeforePoll` — `reconcile/start` +14730 over the storm) returns its deltas uncounted. The 24 h variant is env-gated (`RT_CHURN_SECS=86400`, never a matrix default); all asserts are duration-agnostic. Harness lesson: `A && B &` backgrounds the whole chain — launch runs with bare `nohup … &` only. | -| rt-11-8 | 2026-11-30 | bridge+raw+plain, self-churn (stated vantage: the tenant-with-deployment-rights position — a plain container cannot restart itself; that is not the mechanism under test) | BLOCKED | — | `20261130T042718-848ebbe00-1464077` (18/18) | **Self-churn does not even register.** 20 `docker restart -t 0 rt-attacker` cycles (~4.5 s apart), each re-packing 10000 sockfill loopback pairs (poll_sockets 241→20244): mid-storm victim coverage lag **0 s** (the row's verdict criterion), reconcile `complete` p99 **0.00032 s** (the 1 s reconcileTimeout budget is 3000x above), victim records flowing mid-storm, and post-storm go_goroutines 51→51 / process_open_fds 53→53 / poll_sockets 250 (the map drained; ~20 000 attacker sockets gone), `netns_dropped_total{add_rate}`=0 (the 256-adds/reconcile cap never approached), `reconcile_incomplete_total`=0, RestartCount=0. The reconcile scan is over ~8 netns — the restart churn is noise to it. The rt-4-6 observability finding (#370) applies verbatim: the stores/dels counters stay 0 in this shape. | -| rt-4-8 | 2026-11-30 | bridge+raw+plain, XTCP2_CPUS=2 (the cgroup-cap deploy axis), ATTACKER=admin (TriggerPollBurst is an admin RPC) | BLOCKED | — | `20261130T045657-848ebbe00-1525702` (16/16) | **The quota holds the line; the amplification lands in records, not CPU.** The admin sets the 1 s floor (SetPollFrequency 1 s/500 ms — the floor rt-3-3 landed) and runs TriggerPollBurst 120×1 s under a 2-CPU quota (NanoCpus=2000000000 verified on the container): record rate 116→491 rec/s (**4.2×**, the full-dump-per-poll cost), daemon CPU **130.9%/132.0%** under the burst vs 116% baseline — inside the quota bound (< 210% of the 4-vCPU host) — RSS 24453→27002 kB (no OOM-kill), metrics answers through the burst, post-burst rate settles (491→344→ the 2 s restore), no restart, gRPC Get ok after. The nuance the row now answers: at this population the burst multiplies RECORDS, not CPU (116→131% CPU for 4.2× records — polling is cheap); the quota is the right protection for the CPU leg, and the record-volume residual is #342's family (the burst's own `-count` bounds it). Prod guidance: pin `XTCP2_CPUS` — the default deploy is unlimited. | +| rt-4-6 | 2026-11-30 | bridge+raw+plain, host-side churn driver (stated vantage: the fleet-operator position — a PLAIN attacker cannot create netns; NET_ADMIN does not grant it either, the rt-11-7 ladder) | BLOCKED | S4 (observability, #370) | `20261130T041837-848ebbe00-1287288` (16/16) | **The churn storm loses on every axis.** 149 netns add+del cycles in 240 s (one launch/s, each container: tcp-stress `both` with `-close` — 2500 LISTEN + 2500 client sockets, dead ~2.5 s, `--rm`): poll_sockets 237→7875 mid-storm, daemon CPU 111–114% (of 4 vCPUs; bound 250%), victim records flowing MID-storm, `reconcile_incomplete_total` 0→0 (the 1 s scan budget never tripped). Post-storm convergence (measured: in-flight goroutines take ~2 min to drain — run 1's +15 at 30 s settled to baseline−1 by 4 min, flat — convergence waits, not fixed sleeps): **go_goroutines 51→51, process_open_fds 53→53, poll_sockets back to 245** — the FD convergence is the netns-drain proof (each map entry holds one sockstat fd; a leaked entry = one leaked fd), while the socket gauge only shows no residual sockets: a leaked entry KEEPS its namespace alive and reads ~0 sockets, so the gauge cannot discriminate a leak (review correction: the run's original note claimed "a leaked dead netns counts as 1M unknown sockets" — wrong twice over: the entry reads ~0 sockets, and −maxRecordsPerNetns is 262144 (1<<18), not 1M). No FD leak, no goroutine leak, no restart. **Finding (#370): the row's core mechanism — netns add/del under churn — is invisible in metrics**: `mapReconciler` stores/dels only fire on the 6 h background ticker (never in a 4-min run), and the per-poll reconcile (the ACTUAL discovery path, `reconcileBeforePoll` — `reconcile/start`, ~1/poll) returns its deltas uncounted. The 24 h variant is env-gated (`RT_CHURN_SECS=86400`, never a matrix default); the asserts are ratio/bound-based, and the stores/dels check is informational (a 24 h soak sees the 6 h ticker fire; the day #370 lands the deltas become counted — neither fails the row). Harness lesson: `A && B &` backgrounds the whole chain — launch runs with bare `nohup … &` only. | +| rt-11-8 | 2026-11-30 | bridge+raw+plain, self-churn (stated vantage: the tenant-with-deployment-rights position — a plain container cannot restart itself; that is not the mechanism under test) | BLOCKED | — | `20261130T042718-848ebbe00-1464077` (18/18; re-verified after the msum fix) | **Self-churn does not even register.** 20 `docker restart -t 0 rt-attacker` cycles (~4.5 s apart), each re-packing 10000 sockfill loopback pairs (poll_sockets 241→20244): mid-storm victim coverage lag **0 s** (the row's verdict criterion), reconcile `complete` p99 **0.00032 s** (the 1 s reconcileTimeout budget is 3000x above), victim records flowing mid-storm, and post-storm go_goroutines 51→51 / process_open_fds 53→53 / poll_sockets 250 (the FD convergence is the netns-drain proof — each map entry holds one sockstat fd; the socket gauge alone cannot discriminate, a leaked entry reads ~0 sockets from the kept-alive namespace; ~20 000 attacker sockets gone), `netns_dropped_total{add_rate}`=0, `reconcile_incomplete_total`=0 (review correction: the run's original numbers were read through a broken msum — the awk `$1` escaped twice expanded locally and `\|\| echo 0` hid the syntax error as a permanent 0 — so add_rate/incomplete were NOT actually measured in run 1; the fixed helper reads them in the re-run), RestartCount=0. The reconcile scan is over ~8 netns — the restart churn is noise to it. The rt-4-6 observability finding (#370) applies verbatim: the stores/dels counters stay 0 in this shape. | +| rt-4-8 | 2026-11-30 | bridge+raw+plain, XTCP2_CPUS=2 (the cgroup-cap deploy axis), ATTACKER=admin (TriggerPollBurst is an admin RPC) | BLOCKED | — | `20261130T045657-848ebbe00-1525702` (16/16) | **The quota holds the line; the amplification lands in records, not CPU.** The admin sets the 1 s floor (SetPollFrequency 1 s/500 ms — the floor rt-3-3 landed) and runs TriggerPollBurst 120×1 s under a 2-CPU quota (NanoCpus=2000000000 verified on the container, both quota bounds worked out from XTCP2_CPUS): record rate 116→491 rec/s (**4.2×** — but the TOTAL forced cadence, ~half of it the 1 s-floor ticker SetPollFrequency set, half the burst stacked on top: the daemon runs both, ticker ~1/s + burst ~1/s against the 2 s-cadence 0.5/s baseline), daemon CPU **130.9%/132.0%** under the burst vs 116% baseline — inside the quota bound (< 210% of the 4-vCPU host) — RSS 24453→27002 kB (no OOM-kill), metrics answers through the burst, post-burst rate settles (the sample taken only after the poke counter proves burst completion — a run-1 sample ~40 s in sat MID-burst at the restored 2 s ticker + 1 s burst ≈ 3× baseline, right at the assert bound), no restart, gRPC Get ok after. The nuance the row now answers: at this population the forced cadence multiplies RECORDS, not CPU (116→131% CPU for 4.2× records — polling is cheap); the quota is the right protection for the CPU leg, and the record-volume residual is #342's family (the burst's own `-count` bounds it). Prod guidance: pin `XTCP2_CPUS` — the default deploy is unlimited. | - Severity scale: docs/redteam-plan.md §severity. - Rows are appended, never edited, so the log doubles as the program's diff --git a/vagrant/scenarios/rt-11-5-l2-delivery-kill.sh b/vagrant/scenarios/rt-11-5-l2-delivery-kill.sh index d5eb4b783..32de3ab2d 100644 --- a/vagrant/scenarios/rt-11-5-l2-delivery-kill.sh +++ b/vagrant/scenarios/rt-11-5-l2-delivery-kill.sh @@ -225,7 +225,7 @@ W2B="$(tcp_write_err)" # Widen the error window before settling for a verdict: cycle 1's error # burst can leave the queue worker in a full-jitter BACKOFF window, where # no write is ATTEMPTED so nothing errors — poll for the counter while the -# poison is still active (measured race: matrix run 20261130T05xx, cycle 2 +# poison is still active (measured race: matrix run 20261130T064858, cycle 2 # flat at 9->9 over the fixed 18 s window, dark the whole time, healed on # de-poison — every verdict criterion held; the solo re-run errored 11->13 # in-window). diff --git a/vagrant/scenarios/rt-11-8-self-churn.sh b/vagrant/scenarios/rt-11-8-self-churn.sh index c0ea937e3..a36216643 100644 --- a/vagrant/scenarios/rt-11-8-self-churn.sh +++ b/vagrant/scenarios/rt-11-8-self-churn.sh @@ -60,7 +60,12 @@ mval() { # mval — one metrics series' value (absent = 0) } msum() { # msum — SUM of all matching series (label fan-out) - vm_exec victim "curl -s -m 6 -H 'Authorization: Bearer $RT_READ_TOKEN' http://127.0.0.1:9088/metrics | grep '$1' | grep -v '^#' | grep -oE '[0-9.e+-]+\$' | awk '{s+=\\$1} END{print s+0}'" || echo 0 + # NOTE: the awk program sits inside a double-quoted string, so $1 must be + # escaped ONCE (\$1) — the file carried \\$1, which expands locally to the + # series substring and gives awk a syntax error that || echo 0 then hid + # as a permanent 0 (this exact bug made every msum read in this scenario + # return 0 until the review caught it; rt-4-6's copy was correct). + vm_exec victim "curl -s -m 6 -H 'Authorization: Bearer $RT_READ_TOKEN' http://127.0.0.1:9088/metrics | grep '$1' | grep -v '^#' | grep -oE '[0-9.e+-]+\$' | awk '{s+=\$1} END{print s+0}'" || echo 0 } qval() { # qval — a summary quantile's value @@ -71,6 +76,19 @@ daemon_restarts() { vm_exec victim "sudo docker inspect rt-xtcp2 --format '{{.RestartCount}}'" } +# cleanup: idempotent teardown for the pass path, the set -e path (wait_for +# returns 1 on timeout — an un-trapped exit would leave the restart driver +# and its sockfill running on the victim VM, biting the next scenario), and +# the finish() exit below (trap fires on both exit codes). Registered before +# the driver launches so every path after deploy is covered. +cleanup() { + vm_exec_root victim "pkill -f rt-11-8-self.sh" >/dev/null 2>&1 || true + vm_exec victim "sudo docker exec rt-attacker pkill -f sockfill" >/dev/null 2>&1 || true + vm_exec_root victim "cat /tmp/rt-11-8-self.log" >"$RT_EVIDENCE/self-churn.log" 2>/dev/null || true + vm_exec victim "sudo docker restart rt-attacker" >/dev/null 2>&1 || true +} +trap cleanup EXIT + # victim_lag_s: worst age of the two victim namespaces' newest records at # the catcher (the rt-11-4 helper verbatim — one line: multi-line payloads # do not survive vm_exec_root's %q layer). @@ -230,19 +248,20 @@ else not_ok "FD leak: process_open_fds $B_FDS -> $A_FDS never settled below baseline+30 — see evidence" fi -# the netns map drained — proven by the socket gauge (a leaked dead netns -# counts as unknown = -maxRecordsPerNetns = 1M sockets in poll_sockets); the -# mapReconciler stores/dels counters are NOT usable here: the 6h background -# ticker never ticks in a 4-min run, and the per-poll reconcile (the ACTUAL -# discovery path) returns its deltas uncounted — the rt-4-6 observability -# finding applies verbatim. sockfill is killed above, so baseline is the -# honest target. +# the socket map settled — note what this can and cannot prove. Each map +# entry holds an open sockstat fd (pkg/xtcp/sockstat.go: opened once in +# netNamespaceInstance, re-read at offset 0 each poll) that KEEPS its +# namespace alive, so an entry that leaked past its dead netns keeps +# reading ~0 sockets from the (empty) namespace — the gauge returns to +# baseline either way, so it is NOT a leak detector. The FD convergence +# above is the leak detector (a leaked entry = one leaked fd). sockfill is +# killed above, so baseline is the honest target for residual sockets. if settle_bound 'poll_sockets ' $((B_SOCK + 1000)); then A_SOCK="$(mval 'poll_sockets ')" - ok "the netns map drained: poll_sockets back to $A_SOCK (baseline $B_SOCK, ~$((RT_PAIRS * 2)) attacker sockets gone)" + ok "the socket map settled: poll_sockets back to $A_SOCK (baseline $B_SOCK, ~$((RT_PAIRS * 2)) attacker sockets gone; the FD convergence above is the netns-drain proof — a leaked entry reads ~0 sockets, not a spike, so the gauge alone cannot discriminate)" else A_SOCK="$(mval 'poll_sockets ')" - not_ok "poll_sockets stuck at $A_SOCK — dead namespaces not forgotten; see evidence" + not_ok "poll_sockets stuck at $A_SOCK — residual sockets from dead namespaces; see evidence" fi if [ "$A_ADDRATE" -eq 0 ] 2>/dev/null; then @@ -276,12 +295,9 @@ else fi # ============================================================================= -# teardown +# teardown (the EXIT trap runs it on the pass, fail, and set -e paths) # ============================================================================= -vm_exec_root victim "pkill -f rt-11-8-self.sh" >/dev/null 2>&1 || true -vm_exec victim "sudo docker exec rt-attacker pkill -f sockfill" >/dev/null 2>&1 || true -vm_exec_root victim "cat /tmp/rt-11-8-self.log" >"$RT_EVIDENCE/self-churn.log" 2>/dev/null || true -vm_exec victim "sudo docker restart rt-attacker" >/dev/null 2>&1 || true +cleanup finish rt-11-8 "$XTCP2_EXPECT" diff --git a/vagrant/scenarios/rt-4-6-namespace-churn.sh b/vagrant/scenarios/rt-4-6-namespace-churn.sh index 0e295e8b7..6619702ba 100644 --- a/vagrant/scenarios/rt-4-6-namespace-churn.sh +++ b/vagrant/scenarios/rt-4-6-namespace-churn.sh @@ -96,6 +96,22 @@ daemon_restarts() { vm_exec victim "sudo docker inspect rt-xtcp2 --format '{{.RestartCount}}'" } +# cleanup: idempotent teardown for the pass path, the set -e path (wait_for +# returns 1 on timeout — an un-trapped exit would leave the churn driver and +# its containers running on the victim VM, biting the next scenario), and +# the finish() exit below (trap fires on both exit codes). Registered before +# the driver launches so every path after deploy is covered. +cleanup() { + vm_exec_root victim "pkill -f rt-4-6-churn.sh" >/dev/null 2>&1 || true + local i=1 + while [ "$i" -le "${RT_CHURN_SLOTS:-4}" ]; do + vm_exec victim "sudo docker rm -f rt-churn-$i" >/dev/null 2>&1 || true + i=$((i + 1)) + done + vm_exec_root victim "cat /tmp/rt-4-6-churn.log" >"$RT_EVIDENCE/churn.log" 2>/dev/null || true +} +trap cleanup EXIT + # ============================================================================= # deploy + baseline # ============================================================================= @@ -110,7 +126,11 @@ B_FDS="$(mval 'process_open_fds')" B_GORO="$(mval 'go_goroutines')" B_SOCK="$(mval 'poll_sockets ')" B_INCOMPLETE="$(msum 'reconcile_incomplete')" -B_RECONCILES="$(mval 'variable=\"start\"')" # reconcile/start: one per poll +# NOTE: reconcile/start is matched with its FULL label set — 'variable="start"' +# alone is ambiguous (NINE series carry it; sorted first is Deserialize/start, +# the envelope-deserialization counter, ~60/s here — a run measured +14730 of +# those and mislabeled them reconcile starts). +B_RECONCILES="$(mval 'function=\"reconcile\",type=\"count\",variable=\"start\"')" # reconcile/start: one per poll B_CPU="$(daemon_cpu_pct)" ok "baseline: FDs=$B_FDS goroutines=$B_GORO poll_sockets=$B_SOCK cpu=${B_CPU}% incomplete=$B_INCOMPLETE reconciles=$B_RECONCILES" @@ -214,7 +234,7 @@ settle_bound() { # settle_bound — poll up to 180s for <= boun } B_RECONCILES="${B_RECONCILES:-0}" -A_RECONCILES="$(mval 'variable=\"start\"')" +A_RECONCILES="$(mval 'function=\"reconcile\",type=\"count\",variable=\"start\"')" if settle_bound 'go_goroutines' $((B_GORO + 10)); then A_GORO="$(mval 'go_goroutines')" @@ -231,35 +251,46 @@ else not_ok "FD leak: process_open_fds $B_FDS -> $A_FDS never settled below baseline+30 — see evidence" fi -# the netns map drained — proven by the socket gauge, not mapReconciler -# counters (see the observability finding below): every tracked namespace's -# sockstat feeds poll_sockets, and an entry that leaked past its dead netns -# counts as unknown = -maxRecordsPerNetns (1M), so a single leaked entry -# would spike the gauge; baseline-level means every churn netns was -# forgotten. +# the socket map settled — note what this can and cannot prove. Each map +# entry holds an open sockstat fd (pkg/xtcp/sockstat.go: opened once in +# netNamespaceInstance, re-read at offset 0 each poll) that KEEPS its +# namespace alive, so an entry that leaked past its dead netns keeps +# reading ~0 sockets from the (empty) namespace — it never reads as +# "unknown" and the gauge returns to baseline either way. The FD +# convergence above is the leak detector (a leaked entry = one leaked +# fd). This check catches residual SOCKETS: a stalled dump pipeline would +# leave the gauge elevated mid-baseline. if settle_bound 'poll_sockets ' $((B_SOCK + 500)); then A_SOCK="$(mval 'poll_sockets ')" - ok "the netns map drained: poll_sockets back to $A_SOCK (baseline $B_SOCK; a leaked dead netns would count 1M unknown sockets)" + ok "the socket map settled: poll_sockets back to $A_SOCK (baseline $B_SOCK; the FD convergence above is the netns-drain proof — a leaked entry reads ~0 sockets, not a spike, so the gauge alone cannot discriminate)" else A_SOCK="$(mval 'poll_sockets ')" - not_ok "poll_sockets stuck at $A_SOCK vs baseline $B_SOCK — dead namespaces not forgotten; see evidence" + not_ok "poll_sockets stuck at $A_SOCK vs baseline $B_SOCK — residual sockets from dead namespaces; see evidence" fi -# OBSERVABILITY FINDING (measured, asserted): the row's core mechanism — -# netns add/del under churn — is invisible in metrics in the default shape. -# mapReconciler's stores/dels counters only fire on the 6h background -# ticker (never in a 4-min run); the per-poll reconcile (reconcile/start, -# one per poll — the ACTUAL discovery path, reconcileBeforePoll) returns its -# deltas uncounted (poller.go reconcileThenPoll logs them at debug>10 and -# drops them). -A_STORES="$(mval 'variable=\"stores\"')" -A_DELS="$(mval 'variable=\"dels\"')" +# OBSERVABILITY FINDING (measured, informational): the row's core +# mechanism — netns add/del under churn — is invisible in metrics in the +# default shape. mapReconciler's stores/dels counters only fire on the 6h +# background ticker; the per-poll reconcile (reconcile/start, one per poll +# — the ACTUAL discovery path, reconcileBeforePoll) returns its deltas +# uncounted (poller.go reconcileThenPoll logs them at debug>10 and drops +# them). INFORMATIONAL, not a hard assert: a 24 h soak (RT_CHURN_SECS=86400) +# DOES see the 6h ticker fire, and the day #370 lands the per-poll deltas +# become counted — neither is a failure of this row. +A_STORES="$(mval 'function=\"mapReconciler\",type=\"count\",variable=\"stores\"')" +A_DELS="$(mval 'function=\"mapReconciler\",type=\"count\",variable=\"dels\"')" RECON_DELTA=$((A_RECONCILES - B_RECONCILES)) -echo "rt-4-6: post-storm reconcile/start delta=$RECON_DELTA mapReconciler stores=$A_STORES dels=$A_DELS" -if [ "$RECON_DELTA" -ge $((CYCLES / 2)) ] 2>/dev/null && [ "$A_STORES" -eq 0 ] && [ "$A_DELS" -eq 0 ]; then - ok "the churn reconciled per-poll (reconcile/start +$RECON_DELTA) but netns add/del is UNCOUNTED in this shape (mapReconciler stores/dels=0: the 6h ticker never ticks; the per-poll deltas are dropped) — observability gap, filed" +# reconcile/start fires once per poll (2s); the window is the storm + the +# ~30s warmup + up to 180s of settle polling, so half the window's expected +# polls is a safe floor (a vanished series reads 0 -> negative delta -> fail). +EXP_POLLS=$(( (RT_CHURN_SECS + 240) / 2 )) +echo "rt-4-6: post-storm reconcile/start delta=$RECON_DELTA (expected ~$EXP_POLLS polls) mapReconciler stores=$A_STORES dels=$A_DELS" +if [ "$RECON_DELTA" -ge $((EXP_POLLS / 2)) ] 2>/dev/null && [ "$A_STORES" -eq 0 ] && [ "$A_DELS" -eq 0 ]; then + ok "the poller ran through the storm (reconcile/start +$RECON_DELTA, ~1/poll) while netns add/del stayed UNCOUNTED in this window (mapReconciler stores/dels=0: the 6h ticker never ticked; the per-poll deltas are dropped) — observability gap, filed as #370" +elif [ "$RECON_DELTA" -ge $((EXP_POLLS / 2)) ] 2>/dev/null; then + ok "the poller ran through the storm (reconcile/start +$RECON_DELTA) and mapReconciler counted stores=$A_STORES dels=$A_DELS (the 6h ticker fired — a $((RT_CHURN_SECS / 3600))h window sees it; the per-poll deltas remain #370)" else - not_ok "reconcile/start delta=$RECON_DELTA vs $CYCLES cycles, stores=$A_STORES dels=$A_DELS — the churn may not have reached the reconciler; see evidence" + not_ok "reconcile/start delta=$RECON_DELTA vs ~$EXP_POLLS expected polls — the poller may have stalled under churn; see evidence" fi A_INCOMPLETE="$(msum 'reconcile_incomplete')" @@ -288,15 +319,9 @@ else fi # ============================================================================= -# teardown +# teardown (the EXIT trap runs it on the pass, fail, and set -e paths) # ============================================================================= -vm_exec_root victim "pkill -f rt-4-6-churn.sh" >/dev/null 2>&1 || true -i=1 -while [ "$i" -le "$RT_CHURN_SLOTS" ]; do - vm_exec victim "sudo docker rm -f rt-churn-$i" >/dev/null 2>&1 || true - i=$((i + 1)) -done -vm_exec_root victim "cat /tmp/rt-4-6-churn.log" >"$RT_EVIDENCE/churn.log" 2>/dev/null || true +cleanup finish rt-4-6 "$XTCP2_EXPECT" diff --git a/vagrant/scenarios/rt-4-8-poll-amplification-cpu-quota.sh b/vagrant/scenarios/rt-4-8-poll-amplification-cpu-quota.sh index d2648afac..b3bd5bc6b 100644 --- a/vagrant/scenarios/rt-4-8-poll-amplification-cpu-quota.sh +++ b/vagrant/scenarios/rt-4-8-poll-amplification-cpu-quota.sh @@ -76,6 +76,24 @@ scrape_code() { vm_exec victim "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:9088/metrics" } +mval() { # mval — one metrics series' value (absent = 0) + local v + v="$(vm_exec victim "curl -s -m 6 -H 'Authorization: Bearer $RT_READ_TOKEN' http://127.0.0.1:9088/metrics | grep '$1' | grep -v '^#' | grep -oE '[0-9.e+-]+\$' | head -1" || true)" + echo "${v:-0}" +} + +# cleanup: restore the harness-default poll cadence on the fail paths (a +# set -e exit mid-burst would otherwise leave the 1 s floor set; the pass +# path restores explicitly below — idempotent). Registered before the burst. +RT_BURST_RUN=0 +cleanup() { + if [ "$RT_BURST_RUN" = 1 ]; then + vm_exec attacker "$CTL set-poll-frequency $CTL_ARGS '$admin_token' -frequency 2s -timeout 1s" \ + >"$RT_EVIDENCE/restore-trap.log" 2>&1 || true + fi +} +trap cleanup EXIT + # rate : victim-catcher records/s over the last window rate() { local secs="$1" a b @@ -93,12 +111,14 @@ xtcp2_deploy victim attacker wait_for 120 "daemon answers on the victim VM" vm_exec victim \ "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:9088/metrics | grep -qE '^(200|401|403)\$'" victim_still_reporting_tap +xtcp2_victim_read_token # the mval/poke reads below need the bearer token QUOTA_SET="$(vm_exec victim "sudo docker inspect rt-xtcp2 --format '{{.HostConfig.NanoCpus}}'")" -if [ "${QUOTA_SET:-0}" -ge 2000000000 ] 2>/dev/null; then - ok "the quota is set on the daemon container (NanoCpus=$QUOTA_SET = $XTCP2_CPUS CPUs)" +QUOTA_NANO=$((XTCP2_CPUS * 1000000000)) +if [ "${QUOTA_SET:-0}" -eq "$QUOTA_NANO" ] 2>/dev/null; then + ok "the quota is set on the daemon container (NanoCpus=$QUOTA_SET = $XTCP2_CPUS CPUs, worked out from XTCP2_CPUS)" else - not_ok "no cpu quota on the daemon container (NanoCpus=${QUOTA_SET:-unset}) — the XTCP2_CPUS axis did not deploy; see evidence" + not_ok "the cpu quota on the daemon container is NanoCpus=${QUOTA_SET:-unset}, want $QUOTA_NANO — the XTCP2_CPUS axis did not deploy; see evidence" fi admin_token="$(vm_exec victim 'sudo docker exec rt-attacker cat /run/secrets/admin')" @@ -133,12 +153,21 @@ vm_exec attacker "$CTL poll-burst $CTL_ARGS '$admin_token' -count 120 -interval >"$RT_EVIDENCE/poll-burst.log" 2>&1 || true if grep -q "ok: burst" "$RT_EVIDENCE/poll-burst.log"; then ok "the admin burst was accepted and ran (120 polls at the 1 s floor)" + RT_BURST_RUN=1 # the EXIT trap restores the cadence from here on else not_ok "the poll burst did not run — see evidence" fi # measure DURING the burst: the CPU samples and the record rate over the -# same window (the burst writes one poll per second for ~2 min) +# same window. ATTRIBUTION (measured, run 1): the burst interval is 1 s AND +# the SetPollFrequency above set the ticker to the 1 s floor — the daemon +# runs BOTH (pollBurstRunner pokes pollRequestCh independently; the ticker +# keeps ticking), so the mid-burst poll rate is ~2/s (ticker 1/s + burst +# 1/s) against the 2 s-cadence baseline of 0.5/s: roughly HALF the +# amplification is the ticker itself, half the burst. Both are the row's +# premise (the floor is the maximum honored cadence an admin can force — +# the burst stacks on top), but the number is the TOTAL, not the burst's +# alone. CPU1="$(daemon_cpu_pct)" R_RATE="$(rate 20)" CPU2="$(daemon_cpu_pct)" @@ -146,17 +175,18 @@ R_RSS="$(daemon_rss_kb)" echo "rt-4-8: mid-burst cpu=$CPU1%/$CPU2% rate=${R_RATE} rec/s rss=${R_RSS}kB (baseline ${B_RATE} rec/s, ${B_RSS}kB)" if [ "${R_RATE:-0}" -ge $((B_RATE * 2)) ] 2>/dev/null; then - ok "the amplification is real: record rate ${B_RATE} -> ${R_RATE} rec/s under the burst (the full-dump-per-poll cost)" + ok "the amplification is real: record rate ${B_RATE} -> ${R_RATE} rec/s mid-burst (ticker 1/s + burst 1/s = ~4x the 0.5/s baseline — the full-dump-per-poll cost at the maximum forced cadence; ~half is the 1 s-floor ticker, half the burst)" else not_ok "record rate only ${B_RATE} -> ${R_RATE} rec/s — the burst may not have amplified; see evidence" fi -# THE ROW'S CLAUSE: the quota bounds the CPU. 4 vCPUs on the victim; the -# 2-CPU quota caps docker stats at ~200%; slack for the sampling window. -if [ "${CPU1%.*}" -le 210 ] 2>/dev/null && [ "${CPU2%.*}" -le 210 ] 2>/dev/null; then - ok "cgroup protection: daemon CPU ${CPU1}% then ${CPU2}% under the burst, inside the ${XTCP2_CPUS}-CPU quota (< 210% of the 4-vCPU host)" +# THE ROW'S CLAUSE: the quota bounds the CPU. Worked out from XTCP2_CPUS +# (not hard-coded): 100% per quota CPU + 10% slack for the sampling window. +RT_CPU_BOUND=$((XTCP2_CPUS * 100 + 10)) +if [ "${CPU1%.*}" -le "$RT_CPU_BOUND" ] 2>/dev/null && [ "${CPU2%.*}" -le "$RT_CPU_BOUND" ] 2>/dev/null; then + ok "cgroup protection: daemon CPU ${CPU1}% then ${CPU2}% under the burst, inside the ${XTCP2_CPUS}-CPU quota (< ${RT_CPU_BOUND}% of the 4-vCPU host)" else - not_ok "daemon CPU ${CPU1}%/${CPU2}% exceeded the ${XTCP2_CPUS}-CPU quota bound — see evidence" + not_ok "daemon CPU ${CPU1}%/${CPU2}% exceeded the ${XTCP2_CPUS}-CPU quota bound (${RT_CPU_BOUND}%) — see evidence" fi if [ "${CPU1%.*}" -ge 20 ] 2>/dev/null || [ "${CPU2%.*}" -ge 20 ] 2>/dev/null; then @@ -186,17 +216,37 @@ fi # after the burst: healthy, restored, bounded # ============================================================================= -# restore the harness defaults (poll 2s / timeout 1s — the rt-3-3 restore) +# WAIT OUT THE BURST before sampling (run 1's lesson): the poll-burst RPC +# returns immediately and SetPollFrequency does NOT stop a running burst +# (pollBurstRunner pokes on its own 1 s cadence for -count seconds), so a +# sample taken before the last poke lands MID-burst — at the restored 2 s +# ticker + 1 s burst ≈ 1.5 polls/s = 3x the 0.5/s baseline, exactly at the +# assert bound below (flaky). The poke counter (pollBurstRunner/poke, one +# per poke) reaching 120 is the daemon's own view of burst completion. +# RESTORE FIRST (also on this path, so the wait measures the ticker at its +# harness default; the EXIT trap makes it idempotent). vm_exec attacker "$CTL set-poll-frequency $CTL_ARGS '$admin_token' -frequency 2s -timeout 1s" \ >"$RT_EVIDENCE/restore.log" 2>&1 || true -sleep 10 # let the burst drain +burst_done() { + # poke + pokeDropped (disjoint branches in pollBurstRunner) = every poke + # the burst issued; poke alone can stall below 120 when a poke is subsumed + # by an already-queued poll (pokeDropped is not a completion failure). + local p pd + p="$(mval 'function=\"pollBurstRunner\",type=\"count\",variable=\"poke\"')" + pd="$(mval 'function=\"pollBurstRunner\",type=\"count\",variable=\"pokeDropped\"')" + case "$p$pd" in '' | *[!0-9]*) return 1 ;; esac + [ $((p + pd)) -ge 120 ] +} +wait_for 240 "the burst ran to completion (pollBurstRunner poke+pokeDropped reached 120)" burst_done + +sleep 10 # let the in-flight dump drain A_RATE="$(rate 12)" A_CPU="$(daemon_cpu_pct)" A_RSS="$(daemon_rss_kb)" echo "rt-4-8: post-burst rate=${A_RATE} rec/s cpu=${A_CPU}% rss=${A_RSS}kB" -if [ "$A_RATE" -le $((B_RATE * 3)) ] 2>/dev/null; then - ok "the record rate settles back (post-burst ${A_RATE} rec/s vs baseline ${B_RATE})" +if [ "$A_RATE" -le $((B_RATE * 2)) ] 2>/dev/null; then + ok "the record rate settles back (post-burst ${A_RATE} rec/s vs baseline ${B_RATE}, ticker at its 2 s default again)" else not_ok "record rate still ${A_RATE} rec/s post-burst vs baseline ${B_RATE} — see evidence" fi From 7b4e3808eb4eed9af4ea63aa6f8a77b16fdc3031 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Mon, 30 Nov 2026 13:31:17 -0800 Subject: [PATCH 4/6] fix(redteam): rt-4-6 bound calibration (run 3: 101 cycles vs a /2 gate of 120) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The driver cadence is 1.6-2.4 s per cycle (docker rm -f + docker run -d + sleep 1, each container packing 2500 LISTEN + 2500 dials), so 240 s yields 101-149 cycles — the /2 bound (120) failed a healthy run (101 cycles, every product assert green, the storm itself real). /3 (80). The expected-polls formula tightens to storm+60s (measured: 131 polls over the window — the +240s settle slack over-estimated it). --- vagrant/scenarios/rt-4-6-namespace-churn.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/vagrant/scenarios/rt-4-6-namespace-churn.sh b/vagrant/scenarios/rt-4-6-namespace-churn.sh index 6619702ba..32d7a878a 100644 --- a/vagrant/scenarios/rt-4-6-namespace-churn.sh +++ b/vagrant/scenarios/rt-4-6-namespace-churn.sh @@ -212,7 +212,12 @@ wait_for $((RT_CHURN_SECS + 120)) "the churn driver finishes" vm_exec_root victi CYCLES="$(vm_exec_root victim "grep -c '^cycle=' /tmp/rt-4-6-churn.log || true")" CYCLES="${CYCLES:-0}" echo "rt-4-6: driver ran $CYCLES cycles (target ~$((RT_CHURN_SECS / RT_CHURN_CYCLE)))" -if [ "$CYCLES" -ge $((RT_CHURN_SECS / RT_CHURN_CYCLE / 2)) ] 2>/dev/null; then +if [ "$CYCLES" -ge $((RT_CHURN_SECS / RT_CHURN_CYCLE / 3)) ] 2>/dev/null; then + # /3, not /2: the measured driver cadence is 1.6-2.4 s per cycle (docker + # rm -f + docker run -d + sleep 1, each container packing 2500 LISTEN + + # 2500 dials), so 240 s yields 101-149 cycles — a /2 bound (120) failed + # a healthy run (run 3, 101 cycles: a driver-speed gate, not a product + # verdict — the storm itself was real and every product assert held). ok "the churn ran at scale: $CYCLES netns add+del cycles" else not_ok "only $CYCLES churn cycles — the driver under-ran; see evidence" @@ -281,9 +286,10 @@ A_STORES="$(mval 'function=\"mapReconciler\",type=\"count\",variable=\"stores\"' A_DELS="$(mval 'function=\"mapReconciler\",type=\"count\",variable=\"dels\"')" RECON_DELTA=$((A_RECONCILES - B_RECONCILES)) # reconcile/start fires once per poll (2s); the window is the storm + the -# ~30s warmup + up to 180s of settle polling, so half the window's expected -# polls is a safe floor (a vanished series reads 0 -> negative delta -> fail). -EXP_POLLS=$(( (RT_CHURN_SECS + 240) / 2 )) +# ~30s warmup + read overheads (~1 poll per 2s of wall time — measured run 3: +# 131 polls over the storm window), so half the window's expected polls is a +# safe floor (a vanished series reads 0 -> negative delta -> fail). +EXP_POLLS=$(( (RT_CHURN_SECS + 60) / 2 )) echo "rt-4-6: post-storm reconcile/start delta=$RECON_DELTA (expected ~$EXP_POLLS polls) mapReconciler stores=$A_STORES dels=$A_DELS" if [ "$RECON_DELTA" -ge $((EXP_POLLS / 2)) ] 2>/dev/null && [ "$A_STORES" -eq 0 ] && [ "$A_DELS" -eq 0 ]; then ok "the poller ran through the storm (reconcile/start +$RECON_DELTA, ~1/poll) while netns add/del stayed UNCOUNTED in this window (mapReconciler stores/dels=0: the 6h ticker never ticked; the per-poll deltas are dropped) — observability gap, filed as #370" From 8a2d690780c584c9af004ac33cd2624dd22a79db Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Mon, 30 Nov 2026 14:17:39 -0800 Subject: [PATCH 5/6] docs(redteam): re-verification IDs for the review fixes (rt-4-6 16/16, rt-11-8 18/18, rt-4-8 17/17) --- docs/redteam-plan.md | 6 +++--- vagrant/redteam/findings.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/redteam-plan.md b/docs/redteam-plan.md index e00f48c2b..14c73d7ec 100644 --- a/docs/redteam-plan.md +++ b/docs/redteam-plan.md @@ -181,9 +181,9 @@ left auth disabled. These test what admin access is worth. | rt-4-3 | gRPC stream abuse | h2load/ghz: many conns × 20 streams, 4 MB messages, reflection flood | per-conn stream cap 20, 4 MB message limit; no global quota | **VERIFIED 2026-11-25 (BLOCKED — all three legs land inside the guards)**: read-cred oversized `PollFlatRecords` → PermissionDenied ×3 (the method ACL answers BEFORE the recv cap — `PollFlatRecords` is admin-served, so a read credential never reaches the size check and cannot even enumerate the method); admin-cred oversized → ResourceExhausted ×3 (MaxRecvMsgSize=4MB answers); the reading storm (10 conns × 20 streams × 100 rec/s, 60 s) → goroutines 71→299 (linear, ~1/stream + ~5/conn), scrape 200, catcher flowing, 1.1 M records delivered, no leak after (71→299→71). Unauthenticated reflection is the rt-1-2 shape (same StreamServerInterceptor) | bounded degradation only; assert no goroutine leak after close (metrics//`/debug` after test — or pprof via loopback) | S3 | | rt-4-4 | Slow FlatRecords consumer | open authenticated stream, read 1 msg/30 s, never cancel | gRPC flow control should backpressure the daemon pipeline | **VERIFIED 2026-11-25 (BLOCKED on the OOM axis — and the backpressure is the finding)**: 4 paced readers (1 msg/30 s) for 240 s — RSS slope −17 KiB/s (29 MiB flat; envelope row/byte caps + record pool hold), daemon alive. But sink delivery COLLAPSED to the readers' pace: catcher 1494 → **0 lines/6 s** while held, and exactly 32 records crossed in 240 s — the 4 × 8 paced reads, no more. `flatRecordServiceSend`'s blocking per-client Send runs on the record hot path, so the whole pipeline (envelope flush included) is coupled to the slowest reader: the rt-11-3 wedge, paced. 1 h soak via `RT_SOAK=1h` (env-gated, not in the matrix) | daemon memory bounded under stalled consumers for 1 h; no OOM; record the envelope-buffer high-water mark | S3 | | rt-4-5 | Scrape storm | 100 parallel scrapes of `/metrics`, `/metrics-all`, detail paths | 10 in-flight cap on main path; category caps 4; 10 s handler timeouts | **VERIFIED 2026-11-25 (BLOCKED)**: the fast path self-throttles (100x 200, p99 11 ms — the ~17 ms body answers faster than staggered curls stack 10-deep) and the cap engages where a pileup could form: `/metrics-all` 10x 503, `/metrics/link` 3x 503, zero failed conns, no pileup (clean scrape 1.9 ms after), healthz 200, catcher flowing throughout | 503/queue behavior matches docs; no pileup; p99 latency recorded | S4 | -| rt-4-6 | Namespace/socket churn storm | run `nsTest` + a script creating/destroying netns and 10k sockets rapidly in co-tenant containers visible to the daemon | reconcile before each poll; retry loops for vanished veths | **VERIFIED 2026-11-30 (BLOCKED — the storm loses on every axis)**: 149 netns add+del cycles in 240 s (one launch/s, each container 2500 LISTEN + 2500 client sockets, dead ~2.5 s, `--rm`): poll_sockets 237→7875 mid-storm, CPU 111–114% of 4 vCPUs, victim records flowing MID-storm, `reconcile_incomplete_total` 0→0; post-storm convergence **go_goroutines 51→51, process_open_fds 53→53, poll_sockets 245** — the FD convergence is the netns-drain proof (each map entry holds one sockstat fd; a leaked entry = one leaked fd; the socket gauge alone cannot discriminate — a leaked entry keeps its namespace alive and reads ~0 sockets, never "unknown"; −maxRecordsPerNetns is 262144, not 1M) — no fd leak, no goroutine leak, no restart, 16/16 (`20261130T041837-848ebbe00-1287288`; re-verified after the review's exact-series fix). **Finding #370: netns add/del is invisible in metrics — mapReconciler stores/dels only fire on the 6 h ticker; the per-poll reconcile (the ACTUAL discovery path) returns its deltas uncounted** (measured via `reconcile/start` ~1/poll — the run's original +14730 figure was Deserialize/start, the wrong series). The 24 h variant is env-gated (`RT_CHURN_SECS=86400`), never a matrix default | no fd leak, no goroutine leak, bounded CPU, daemon survives 24 h churn (ties into TODO-SOON AI098) | S2 | +| rt-4-6 | Namespace/socket churn storm | run `nsTest` + a script creating/destroying netns and 10k sockets rapidly in co-tenant containers visible to the daemon | reconcile before each poll; retry loops for vanished veths | **VERIFIED 2026-11-30 (BLOCKED — the storm loses on every axis)**: 149 netns add+del cycles in 240 s (one launch/s, each container 2500 LISTEN + 2500 client sockets, dead ~2.5 s, `--rm`): poll_sockets 237→7875 mid-storm, CPU 111–114% of 4 vCPUs, victim records flowing MID-storm, `reconcile_incomplete_total` 0→0; post-storm convergence **go_goroutines 51→51, process_open_fds 53→53, poll_sockets 245** — the FD convergence is the netns-drain proof (each map entry holds one sockstat fd; a leaked entry = one leaked fd; the socket gauge alone cannot discriminate — a leaked entry keeps its namespace alive and reads ~0 sockets, never "unknown"; −maxRecordsPerNetns is 262144, not 1M) — no fd leak, no goroutine leak, no restart, 16/16 (`20261130T041837-848ebbe00-1287288`; re-verified `20261130T215441-7b4e3808e-453165` after the review's exact-series fix: 118 cycles, reconcile/start delta 130 ≈ 1/poll, stores/dels 0). **Finding #370: netns add/del is invisible in metrics — mapReconciler stores/dels only fire on the 6 h ticker; the per-poll reconcile (the ACTUAL discovery path) returns its deltas uncounted** (measured via `reconcile/start` ~1/poll — the run's original +14730 figure was Deserialize/start, the wrong series). The 24 h variant is env-gated (`RT_CHURN_SECS=86400`), never a matrix default | no fd leak, no goroutine leak, bounded CPU, daemon survives 24 h churn (ties into TODO-SOON AI098) | S2 | | rt-4-7 | Broker-outage buffering | kill the in-VM Redpanda; watch daemon | franz-go backoff with jitter (design doc) | **VERIFIED 2026-11-26 (BLOCKED on the queue sink — split verdict, both halves measured)**: half 2 (s3parquet→Garage, the queue-shaped sink): daemon memory bounded while the sink is down (RSS slope 70 KiB/s; queue depth 16 / 64 MiB, oldest-first eviction), the outage is VISIBLE and COUNTED (`destS3Parquet/upload/error=1` after the backoff, `s3_dropped_total=8`), and minio dials per request so the daemon RECOVERS on endpoint return (objects 1270 → 2375) — the plan's expectation holds. Half 1 (tcp, the catcher): the Write errors immediately on the dead conn (FIN/RST — no stall), the counters light up, polling continues — but the blind is **PERMANENT**: a catcher restart changes nothing (0 lines/6 s with the catcher back; tcpDest never reconnects, #339), only a daemon restart re-dials (measured). The permanent-blind finding is asserted in-row and filed under #339. **FIXED same day (#339 landed with this expectation flip)**: the tcp destination is now a bounded queue + worker — Send never blocks, every write and dial carries `tcp_write_timeout`, a failed write reconnects under full-jitter backoff. Re-verified **BLOCKED 15/15** (evidence `20261126T110001-209ab068a-1548426`): the outage is counted (`destTCP` Write/error=24, Dial/error=25, `xtcp_tcp_dropped_total=9`), polls continue, and **the catcher restart heals delivery with NO daemon restart** (reconnects=1, 2482 lines/6 s after return) — the plan's expectation now holds on BOTH halves | memory bounded while dest is down; recovers on broker return; no unbounded queue | S3 | -| rt-4-8 | Admin-triggered poll amplification | (needs admin) poll burst against a host with 100 containers × 250 sockets | full-dump per poll | **VERIFIED 2026-11-30 (BLOCKED — the quota holds the line)**: the refocused cgroup-cap variant (the XTCP2_CPUS deploy axis, pinned 2, both quota bounds worked out from it; the 100-container population was premortem-refocused as arithmetic — rt-3-3 measured the mechanism). The admin sets the 1 s floor and runs TriggerPollBurst 120×1 s under the quota: record rate 116→491 rec/s (**4.2× — the TOTAL forced cadence: ~half the 1 s-floor ticker, half the burst stacked on top**), daemon CPU **130.9%/132.0%** vs 116% baseline — inside the quota bound, RSS 24453→27002 kB, no OOM-kill, metrics answers through the burst, rate settles post-burst (sampled only after the poke counter proves burst completion — the run-1 "post-burst" sample ~40 s in sat mid-burst), no restart, 16/16 (`20261130T045657-848ebbe00-1525702`; re-verified after the review's burst-completion fix). The nuance: at this population the forced cadence multiplies RECORDS not CPU (116→131% for 4.2× records — polling is cheap); the record-volume residual is #342's family (the burst's `-count` bounds it). Prod guidance: pin XTCP2_CPUS — the default deploy is unlimited | latency/CPU bounded; assert cgroup protection works | S3 | +| rt-4-8 | Admin-triggered poll amplification | (needs admin) poll burst against a host with 100 containers × 250 sockets | full-dump per poll | **VERIFIED 2026-11-30 (BLOCKED — the quota holds the line)**: the refocused cgroup-cap variant (the XTCP2_CPUS deploy axis, pinned 2, both quota bounds worked out from it; the 100-container population was premortem-refocused as arithmetic — rt-3-3 measured the mechanism). The admin sets the 1 s floor and runs TriggerPollBurst 120×1 s under the quota: record rate 116→491 rec/s (**4.2× — the TOTAL forced cadence: ~half the 1 s-floor ticker, half the burst stacked on top**), daemon CPU **130.9%/132.0%** vs 116% baseline — inside the quota bound, RSS 24453→27002 kB, no OOM-kill, metrics answers through the burst, rate settles post-burst (sampled only after the poke counter proves burst completion — the run-1 "post-burst" sample ~40 s in sat mid-burst), no restart, 16/16 (`20261130T045657-848ebbe00-1525702`; re-verified `20261130T221109-7b4e3808e-764112` 17/17 after the review's burst-completion fix — the post-burst sample now waits for the poke counter). The nuance: at this population the forced cadence multiplies RECORDS not CPU (116→131% for 4.2× records — polling is cheap); the record-volume residual is #342's family (the burst's `-count` bounds it). Prod guidance: pin XTCP2_CPUS — the default deploy is unlimited | latency/CPU bounded; assert cgroup protection works | S3 | ### RT-5 Host attacks through xtcp2 (netlink and capabilities) @@ -278,7 +278,7 @@ listeners; true with `--network host` or published ports): | rt-11-5 | L2 kill of the delivery path | if the destination (Kafka/Redpanda, S3 endpoint container) is a sibling on the same bridge, both endpoints are on-path to each other: spoofed RSTs or ARP blackholing of the daemon→broker TCP. franz-go retries with jitter forever, so the daemon looks healthy while delivering nothing | jittered backoff (fleet design); reconnect | **VERIFIED 2026-11-26 (CONFIRMED — stronger than the premise: an L2 stall does not just blind delivery, it freezes COLLECTION)**: a privileged co-tenant (CAP_NET_RAW, sibling on the bridge — a dedicated docker0 alias keeps the gateway path clean so the API stays 200) ARP-blackholed the sink with a 200 ms gratuitous-reply loop (arppoison; existing entries flip with default arp_accept). Measured timeline: delivery dies instantly (0 lines/6 s); the Writes keep SUCCEEDING locally while SO_SNDBUF absorbs envelopes; the buffer fills → the Write blocks → **the whole poller freezes** (polls frozen 14 s at tcp_retries2=8; ~15.4 min at the prod default retries2=15) with **zero error counters** and scrape 200 — fully silent. De-poison mid-window: the buffered envelopes drain, the catcher catches up (1667 lines/6 s), no error counters, **no loss** — the blind is latency, not loss. The window closed (retries2=3): counters light up only then (the row's visibility premise holds, after the gap), polls resume, and delivery is permanently dead until a daemon restart (no reconnect, #339). **Product finding filed (#345)**: SetWriteDeadline + decouple the flush from the poll goroutine. **FIXED same day (#345 + #339 landed with this expectation flip)**: the tcp destination queues to a bounded worker (`Send` never blocks the poller), every write and dial carries `tcp_write_timeout` (default 30 s, deploy axis `XTCP2_TCP_WRITE_TIMEOUT`; this run pins 5 s), and a failed write reconnects under full-jitter backoff. Re-verified **MITIGATED 18/18** (evidence `20261126T111738-209ab068a-1688938`, two full poison cycles): polls keep issuing through the stall (25→47 over 32 s — the freeze is gone), the blind is VISIBLE and COUNTED while dark (Write/error=9, Dial/error=8, `xtcp_tcp_dropped_total=3`, scrape 200), de-poison heals delivery with NO daemon restart (reconnects=1, 2498 lines/6 s), and the second cycle repeats the whole arc (Write/error 10→14, polls 77→82, heals again at 2500 lines/6 s). The residual — delivery still stalls while the route is blackholed — is physics, bounded by the deadline and visible in the counters | assert delivery-failure counters/metrics make the blind *visible* (`xtcp_counts` delivery errors, `xtcp_gauges` delivery health); finding: sustained L2 kill = silent-ish outage without an external watchdog | S2 (fixed) | | rt-11-6 | Host noisy-neighbor starvation | CPU fork bomb without cpu quota, memory pressure toward OOM (xtcp2 has real RSS), **conntrack-table exhaustion** (mass short-lived flows through host NAT → `nf_conntrack: table full` drops the daemon's outbound SYN to Kafka/S3), pid-limit exhaustion breaking the `/proc` walk | container cgroup limits are deployment policy | **VERIFIED 2026-11-28 (BLOCKED — the spray loses; the ops view doesn't)**: the conntrack leg, measured twice (shape B `20261127T232913-…` 16/16; shape A `20261128T031048-…` 17/17). A plain-tier co-tenant spraying ~700 conns/s through docker0 (sockfill -spray: dial, close cleanly — each conn lingers ~120 s as a TIME_WAIT conntrack entry) pins the host netns table in ~20 s against the harness pin of 12288 (stock 262144 needs >2200/s sustained — a fleet, not a myth); dmesg ×1275. Established delivery is immune (49559 lines/6 s with the table full). A forced re-dial against the full table is a race: shape B healed THROUGH the storm (the spray's own TIME_WAIT expiry frees ~max/120 slots/s — 58027 lines/6 s, one counted Dial error); shape A went dark until the drain and the #352 queue bounded it (Dial/error=1, dropped=27, reconnects=1, no restart, polls +64 throughout). The row's real finding: **a fresh scrape through docker-proxy needs a new conntrack entry for the proxy's backend leg, so /metrics times out (000) while records keep flowing** — the monitoring path is the casualty, not collection; heals with the table. "Absence of metrics must itself alert" confirmed end-to-end: during the storm the fleet's own scrape IS the absent metric. | assert per-link effects and that each has a metric the fleet can alert on; finding: "absence of metrics must itself alert" — an external liveness watchdog is a deployment requirement | S2 (finding: the scrape-path blind) | | rt-11-7 | Own-netns parser crash attempt | pathological own netns (max-length ifnames, huge neighbor/route tables, nested veth/macvlan) hoping for a typed-parser panic; a panic in the poll path takes the whole daemon (the link-monitor panic-isolation issue is documented as open) | fixture-tested parsers, fuzz targets | **VERIFIED 2026-11-29 (BLOCKED — the corpus loses; the daemon does not flinch)**: a NET_ADMIN co-tenant builds pathological-but-legal own-netns state — 87 links (15-char IFNAMSIZ-1 names, 255-char ifalias labels, macvlan, vlan 4094, veth-under-bridge), 976 corpus neighbors (all five pathological MAC shapes; `ip neigh` prints 977 with the container's own gateway line), 1012 routes (metrics 0 and 4294967295, a 32-nexthop multipath, v6 zero-MAC fe80::1), fib rules at pref 4294967294/4294967295 — on the new locality deploy axis (`-enrichLocality -localityEvents`), so a rtnetlink listener runs INSIDE the attacker's netns. The attacker cannot send bytes: the kernel serializes the state into well-formed netlink and every message flows through the parsers. Measured: the listener parsed **+1141 corpus events live** through the build (events 108→1249); one forced ROUTE event after the 60 s quiet window fired a full re-dump (snapshot periodic 1→2 — the whole corpus re-parsed through the dump path); through all of it no panic, no restart, scrape 200, catcher grew through the build — a parser panic anywhere takes the daemon (no recover() in the listener path), none tripped. **Measured coverage gap (finding, not a crash): localityGroups excludes GroupNeigh — the deployed daemon never dumps or subscribes to neighbors; the plan's "huge neighbor tables" leg was NOT exercised — the pathological-MAC neighbor corpus is kernel-resident only, a fixture seed for the day the enricher reads neighbors** | daemon survives; any crash = S1-class finding feeding the fixture corpus | -| rt-11-8 | Self-churn + reconcile amplification | rapid own socket churn and `docker restart` loops make discovery/dockermeta/reconcile (which runs before each poll) burn the cycle; AI098 warn-storm | churn handling, retry logic | **VERIFIED 2026-11-30 (BLOCKED — self-churn does not even register)**: 20 `docker restart -t 0 rt-attacker` cycles ~4.5 s apart, each re-packing 10000 sockfill loopback pairs (poll_sockets 241→20244): mid-storm victim coverage lag **0 s** (the row's verdict criterion), reconcile `complete` p99 **0.00032 s** (the 1 s budget is 3000× above), victim records flowing mid-storm, post-storm go_goroutines 51→51 / FDs 53→53 / poll_sockets 250 (the FD convergence is the drain proof), `add_rate`=0, `reconcile_incomplete`=0 (run 1's zeros for these two were read through a broken helper — the awk `$1` escaped twice expanded locally, the syntax error hidden as a permanent 0; re-measured with the fix), no restart, 18/18 (`20261130T042718-848ebbe00-1464077`; re-verified after the review's msum fix). The rt-4-6 observability finding (#370) applies verbatim: stores/dels stay 0 in this shape | bounded reconcile cost; no coverage lag on victim namespaces | +| rt-11-8 | Self-churn + reconcile amplification | rapid own socket churn and `docker restart` loops make discovery/dockermeta/reconcile (which runs before each poll) burn the cycle; AI098 warn-storm | churn handling, retry logic | **VERIFIED 2026-11-30 (BLOCKED — self-churn does not even register)**: 20 `docker restart -t 0 rt-attacker` cycles ~4.5 s apart, each re-packing 10000 sockfill loopback pairs (poll_sockets 241→20244): mid-storm victim coverage lag **0 s** (the row's verdict criterion), reconcile `complete` p99 **0.00032 s** (the 1 s budget is 3000× above), victim records flowing mid-storm, post-storm go_goroutines 51→51 / FDs 53→53 / poll_sockets 250 (the FD convergence is the drain proof), `add_rate`=0, `reconcile_incomplete`=0 (run 1's zeros for these two were read through a broken helper — the awk `$1` escaped twice expanded locally, the syntax error hidden as a permanent 0; re-measured with the fix), no restart, 18/18 (`20261130T042718-848ebbe00-1464077`; re-verified `20261130T220551-7b4e3808e-718451` after the review's msum fix — add_rate/incomplete re-measured as real values). The rt-4-6 observability finding (#370) applies verbatim: stores/dels stay 0 in this shape | bounded reconcile cost; no coverage lag on victim namespaces | **Tier 2 — co-tenant holding only a read credential:** rt-11-1/2/3 still apply unchanged (FDs and stream slots are consumed before authorization, and diff --git a/vagrant/redteam/findings.md b/vagrant/redteam/findings.md index a3a890a10..0cd60e49a 100644 --- a/vagrant/redteam/findings.md +++ b/vagrant/redteam/findings.md @@ -69,9 +69,9 @@ that gets fixed flips its `EXPECT` in the same PR as the fix | rt-11-6 | 2026-11-28 | bridge+raw+plain, SINK_IP=172.17.99.2 (conntrack leg) | BLOCKED | S2 (finding: the scrape-path blind) | `20261128T031048-c0f904e3d-3955865` (shape A), `20261127T232913-b7769a466-1209893` (shape B) | **The conntrack spray cannot stop xtcp2 reporting — but it CAN blind the ops view.** A plain-tier co-tenant (no caps; sockfill -spray, ~700 conns/s — dial, close cleanly, each conn lingers ~120 s as a TIME_WAIT conntrack entry; the harness pins nf_conntrack_max=12288 as time compression — stock 262144 needs >2200/s sustained, i.e. a noisy-neighbor fleet) pins the HOST netns table in ~20 s; dmesg logs `nf_conntrack: table full` ×1275. Measured effects: (1) **established delivery is immune** — 49559 lines/6 s with the table full (its entry is already allocated); (2) a re-dial against the full table is a RACE the daemon usually wins (the storm's own TIME_WAIT expiry frees ~max/120 slots/s): shape B healed THROUGH the storm (58027 lines/6 s mid-storm, one counted Dial error); shape A went dark until the drain and the #352 queue bounded it (Dial/error=1, dropped=27, reconnects=1, delivery healed with NO restart, polls +64 throughout). The two-shape assert accepts both; the only failure is a silent stall. (3) **The real blind: a fresh scrape through docker-proxy needs a new conntrack entry for the proxy's backend leg, so /metrics times out (000) while records keep flowing** — the daemon is fine, the monitoring path is the casualty; heals with the table (401). "Absence of metrics must itself alert" confirmed end-to-end: during the storm the fleet's scrape IS the absent metric. Harness lessons (encoded in-scenario): the vagrant control path is the DHCP mgmt net **192.168.121.0/24, NOT the private /24** — NOTRACK mgmt+private+lo or the storm stalls the scenario's own ssh on SYN retransmits and starves the next provisioning's DNS-over-ens6; a mid-run death MUST reset the pin (defensive ct_reset + EXIT trap) or every following scenario starves; `pgrep -f` matches its own cmdline (listener never started — spray ok=0 for 85 K attempts) and `A || B &` hangs the ssh session (the subshell holds stdout waiting on socat) — check with ss, start bare. | | rt-11-7 | 2026-11-29 | bridge+raw+plain, ENRICH=locality (the -enrichLocality -localityEvents axis) | BLOCKED | none | `20261129T091855-df22997b2-1827895` (18/18) | **The parser corpus loses; the daemon does not even flinch.** A NET_ADMIN co-tenant builds pathological-but-legal own-netns state (all probe-verified kernel-accepted): 87 links (veth pairs with 15-char IFNAMSIZ-1 names, 255-char ifalias labels, macvlan + vlan id 4094 on a veth, a veth enslaved to a bridge), 976 corpus neighbors (39 veths × 25 cycling all five pathological MAC shapes — zero, broadcast, IPv4-mcast 01:00:5e:ff:ff:ff, IPv6-mcast 33:33:…, locally-administered 02:00:… — plus the v6 zero-MAC fe80::1; `ip neigh` prints 977 lines, the +1 being the container's own eth0 gateway), 1012 routes (metrics 0 and 4294967295 — the u32 extremes, a 32-nexthop multipath route, v6 zero-MAC fe80::1 + metric-max /128), fib rules at pref 4294967294/4294967295. The attacker cannot send bytes: the kernel serializes the state into well-formed netlink and the daemon parses it via the per-netns locality listener (deployed on the new locality axis; a fresh container's listener starts within 5 s, probe-verified). Measured: **the listener parsed +1141 corpus events live through the build** (localityListener events 108→1249), a forced ROUTE event after the 60 s quiet window fired a full re-dump (snapshot periodic 1→2 — the whole corpus re-parsed through the dump path), and through all of it: no panic, no restart, scrape 200, the catcher grew through the build (8503→8984 lines/6 s). A parser panic anywhere takes the whole daemon (no recover() in the listener path) — none tripped. **Measured coverage gap (finding, not a crash): localityGroups (pkg/xtcp/enrich_locality_listen.go) excludes GroupNeigh — "Neighbors are not one" — so the deployed daemon never dumps or subscribes to neighbor tables at all; the plan's "huge neighbor tables" leg was NOT exercised — the 976 pathological-MAC neighbors are kernel-resident only** (they seed a fixture corpus for the day the enricher starts reading neighbors). Harness lessons (encoded): 16-char ifnames are kernel-rejected ("Attribute failed policy validation" — IFNAMSIZ enforced); routes on DOWN veths are rejected ("Device for nexthop is not up" — bring links up first); a neigh-replace forced event is INVISIBLE to the listener (probe: events flat at a neigh event, +1 periodic/rebuilds at a route one — force ROUTE events); POSIX sh (dash) rejects `${n/a/b}` — derive peer names with printf; `wait_for` returns 1 on timeout and set -e kills the scenario before its RESULT line — guard with `|| true`; the emitted label order is function,TYPE,variable (read the raw series, and fold absent series to 0). | -| rt-4-6 | 2026-11-30 | bridge+raw+plain, host-side churn driver (stated vantage: the fleet-operator position — a PLAIN attacker cannot create netns; NET_ADMIN does not grant it either, the rt-11-7 ladder) | BLOCKED | S4 (observability, #370) | `20261130T041837-848ebbe00-1287288` (16/16) | **The churn storm loses on every axis.** 149 netns add+del cycles in 240 s (one launch/s, each container: tcp-stress `both` with `-close` — 2500 LISTEN + 2500 client sockets, dead ~2.5 s, `--rm`): poll_sockets 237→7875 mid-storm, daemon CPU 111–114% (of 4 vCPUs; bound 250%), victim records flowing MID-storm, `reconcile_incomplete_total` 0→0 (the 1 s scan budget never tripped). Post-storm convergence (measured: in-flight goroutines take ~2 min to drain — run 1's +15 at 30 s settled to baseline−1 by 4 min, flat — convergence waits, not fixed sleeps): **go_goroutines 51→51, process_open_fds 53→53, poll_sockets back to 245** — the FD convergence is the netns-drain proof (each map entry holds one sockstat fd; a leaked entry = one leaked fd), while the socket gauge only shows no residual sockets: a leaked entry KEEPS its namespace alive and reads ~0 sockets, so the gauge cannot discriminate a leak (review correction: the run's original note claimed "a leaked dead netns counts as 1M unknown sockets" — wrong twice over: the entry reads ~0 sockets, and −maxRecordsPerNetns is 262144 (1<<18), not 1M). No FD leak, no goroutine leak, no restart. **Finding (#370): the row's core mechanism — netns add/del under churn — is invisible in metrics**: `mapReconciler` stores/dels only fire on the 6 h background ticker (never in a 4-min run), and the per-poll reconcile (the ACTUAL discovery path, `reconcileBeforePoll` — `reconcile/start`, ~1/poll) returns its deltas uncounted. The 24 h variant is env-gated (`RT_CHURN_SECS=86400`, never a matrix default); the asserts are ratio/bound-based, and the stores/dels check is informational (a 24 h soak sees the 6 h ticker fire; the day #370 lands the deltas become counted — neither fails the row). Harness lesson: `A && B &` backgrounds the whole chain — launch runs with bare `nohup … &` only. | -| rt-11-8 | 2026-11-30 | bridge+raw+plain, self-churn (stated vantage: the tenant-with-deployment-rights position — a plain container cannot restart itself; that is not the mechanism under test) | BLOCKED | — | `20261130T042718-848ebbe00-1464077` (18/18; re-verified after the msum fix) | **Self-churn does not even register.** 20 `docker restart -t 0 rt-attacker` cycles (~4.5 s apart), each re-packing 10000 sockfill loopback pairs (poll_sockets 241→20244): mid-storm victim coverage lag **0 s** (the row's verdict criterion), reconcile `complete` p99 **0.00032 s** (the 1 s reconcileTimeout budget is 3000x above), victim records flowing mid-storm, and post-storm go_goroutines 51→51 / process_open_fds 53→53 / poll_sockets 250 (the FD convergence is the netns-drain proof — each map entry holds one sockstat fd; the socket gauge alone cannot discriminate, a leaked entry reads ~0 sockets from the kept-alive namespace; ~20 000 attacker sockets gone), `netns_dropped_total{add_rate}`=0, `reconcile_incomplete_total`=0 (review correction: the run's original numbers were read through a broken msum — the awk `$1` escaped twice expanded locally and `\|\| echo 0` hid the syntax error as a permanent 0 — so add_rate/incomplete were NOT actually measured in run 1; the fixed helper reads them in the re-run), RestartCount=0. The reconcile scan is over ~8 netns — the restart churn is noise to it. The rt-4-6 observability finding (#370) applies verbatim: the stores/dels counters stay 0 in this shape. | -| rt-4-8 | 2026-11-30 | bridge+raw+plain, XTCP2_CPUS=2 (the cgroup-cap deploy axis), ATTACKER=admin (TriggerPollBurst is an admin RPC) | BLOCKED | — | `20261130T045657-848ebbe00-1525702` (16/16) | **The quota holds the line; the amplification lands in records, not CPU.** The admin sets the 1 s floor (SetPollFrequency 1 s/500 ms — the floor rt-3-3 landed) and runs TriggerPollBurst 120×1 s under a 2-CPU quota (NanoCpus=2000000000 verified on the container, both quota bounds worked out from XTCP2_CPUS): record rate 116→491 rec/s (**4.2×** — but the TOTAL forced cadence, ~half of it the 1 s-floor ticker SetPollFrequency set, half the burst stacked on top: the daemon runs both, ticker ~1/s + burst ~1/s against the 2 s-cadence 0.5/s baseline), daemon CPU **130.9%/132.0%** under the burst vs 116% baseline — inside the quota bound (< 210% of the 4-vCPU host) — RSS 24453→27002 kB (no OOM-kill), metrics answers through the burst, post-burst rate settles (the sample taken only after the poke counter proves burst completion — a run-1 sample ~40 s in sat MID-burst at the restored 2 s ticker + 1 s burst ≈ 3× baseline, right at the assert bound), no restart, gRPC Get ok after. The nuance the row now answers: at this population the forced cadence multiplies RECORDS, not CPU (116→131% CPU for 4.2× records — polling is cheap); the quota is the right protection for the CPU leg, and the record-volume residual is #342's family (the burst's own `-count` bounds it). Prod guidance: pin `XTCP2_CPUS` — the default deploy is unlimited. | +| rt-4-6 | 2026-11-30 | bridge+raw+plain, host-side churn driver (stated vantage: the fleet-operator position — a PLAIN attacker cannot create netns; NET_ADMIN does not grant it either, the rt-11-7 ladder) | BLOCKED | S4 (observability, #370) | `20261130T041837-848ebbe00-1287288` (16/16; re-verified `20261130T215441-7b4e3808e-453165` after the review's exact-series fix — 118 cycles, poll_sockets 291→8040, CPU 229.64%/141.83%, goroutines 52→52, FDs 53→53, reconcile/start delta 130 ≈ 1/poll, stores/dels 0) | **The churn storm loses on every axis.** 149 netns add+del cycles in 240 s (one launch/s, each container: tcp-stress `both` with `-close` — 2500 LISTEN + 2500 client sockets, dead ~2.5 s, `--rm`): poll_sockets 237→7875 mid-storm, daemon CPU 111–114% (of 4 vCPUs; bound 250%), victim records flowing MID-storm, `reconcile_incomplete_total` 0→0 (the 1 s scan budget never tripped). Post-storm convergence (measured: in-flight goroutines take ~2 min to drain — run 1's +15 at 30 s settled to baseline−1 by 4 min, flat — convergence waits, not fixed sleeps): **go_goroutines 51→51, process_open_fds 53→53, poll_sockets back to 245** — the FD convergence is the netns-drain proof (each map entry holds one sockstat fd; a leaked entry = one leaked fd), while the socket gauge only shows no residual sockets: a leaked entry KEEPS its namespace alive and reads ~0 sockets, so the gauge cannot discriminate a leak (review correction: the run's original note claimed "a leaked dead netns counts as 1M unknown sockets" — wrong twice over: the entry reads ~0 sockets, and −maxRecordsPerNetns is 262144 (1<<18), not 1M). No FD leak, no goroutine leak, no restart. **Finding (#370): the row's core mechanism — netns add/del under churn — is invisible in metrics**: `mapReconciler` stores/dels only fire on the 6 h background ticker (never in a 4-min run), and the per-poll reconcile (the ACTUAL discovery path, `reconcileBeforePoll` — `reconcile/start`, ~1/poll) returns its deltas uncounted. The 24 h variant is env-gated (`RT_CHURN_SECS=86400`, never a matrix default); the asserts are ratio/bound-based, and the stores/dels check is informational (a 24 h soak sees the 6 h ticker fire; the day #370 lands the deltas become counted — neither fails the row). Harness lesson: `A && B &` backgrounds the whole chain — launch runs with bare `nohup … &` only. | +| rt-11-8 | 2026-11-30 | bridge+raw+plain, self-churn (stated vantage: the tenant-with-deployment-rights position — a plain container cannot restart itself; that is not the mechanism under test) | BLOCKED | — | `20261130T042718-848ebbe00-1464077` (18/18; re-verified `20261130T220551-7b4e3808e-718451` after the msum fix — add_rate=0 and incomplete=0 re-measured as real values, reconcile p99 0.00147 s, FDs 53→53) | **Self-churn does not even register.** 20 `docker restart -t 0 rt-attacker` cycles (~4.5 s apart), each re-packing 10000 sockfill loopback pairs (poll_sockets 241→20244): mid-storm victim coverage lag **0 s** (the row's verdict criterion), reconcile `complete` p99 **0.00032 s** (the 1 s reconcileTimeout budget is 3000x above), victim records flowing mid-storm, and post-storm go_goroutines 51→51 / process_open_fds 53→53 / poll_sockets 250 (the FD convergence is the netns-drain proof — each map entry holds one sockstat fd; the socket gauge alone cannot discriminate, a leaked entry reads ~0 sockets from the kept-alive namespace; ~20 000 attacker sockets gone), `netns_dropped_total{add_rate}`=0, `reconcile_incomplete_total`=0 (review correction: the run's original numbers were read through a broken msum — the awk `$1` escaped twice expanded locally and `\|\| echo 0` hid the syntax error as a permanent 0 — so add_rate/incomplete were NOT actually measured in run 1; the fixed helper reads them in the re-run), RestartCount=0. The reconcile scan is over ~8 netns — the restart churn is noise to it. The rt-4-6 observability finding (#370) applies verbatim: the stores/dels counters stay 0 in this shape. | +| rt-4-8 | 2026-11-30 | bridge+raw+plain, XTCP2_CPUS=2 (the cgroup-cap deploy axis), ATTACKER=admin (TriggerPollBurst is an admin RPC) | BLOCKED | — | `20261130T045657-848ebbe00-1525702` (16/16; re-verified `20261130T221109-7b4e3808e-764112` after the review's burst-completion fix — 17/17: baseline 171 rec/s, mid-burst 583 rec/s, post-burst 189 rec/s with the poke counter proving completion, NanoCpus assert exact-equality from XTCP2_CPUS) | **The quota holds the line; the amplification lands in records, not CPU.** The admin sets the 1 s floor (SetPollFrequency 1 s/500 ms — the floor rt-3-3 landed) and runs TriggerPollBurst 120×1 s under a 2-CPU quota (NanoCpus=2000000000 verified on the container, both quota bounds worked out from XTCP2_CPUS): record rate 116→491 rec/s (**4.2×** — but the TOTAL forced cadence, ~half of it the 1 s-floor ticker SetPollFrequency set, half the burst stacked on top: the daemon runs both, ticker ~1/s + burst ~1/s against the 2 s-cadence 0.5/s baseline), daemon CPU **130.9%/132.0%** under the burst vs 116% baseline — inside the quota bound (< 210% of the 4-vCPU host) — RSS 24453→27002 kB (no OOM-kill), metrics answers through the burst, post-burst rate settles (the sample taken only after the poke counter proves burst completion — a run-1 sample ~40 s in sat MID-burst at the restored 2 s ticker + 1 s burst ≈ 3× baseline, right at the assert bound), no restart, gRPC Get ok after. The nuance the row now answers: at this population the forced cadence multiplies RECORDS, not CPU (116→131% CPU for 4.2× records — polling is cheap); the quota is the right protection for the CPU leg, and the record-volume residual is #342's family (the burst's own `-count` bounds it). Prod guidance: pin `XTCP2_CPUS` — the default deploy is unlimited. | - Severity scale: docs/redteam-plan.md §severity. - Rows are appended, never edited, so the log doubles as the program's From a9ce6782ab2c914e460cbaba86f169448c6c79d0 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Mon, 30 Nov 2026 16:10:11 -0800 Subject: [PATCH 6/6] docs(redteam): the 38/38 post-review full-matrix regression (20261201T000311-8a2d69078) --- 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 a3c3e1504..2d270b16e 100644 --- a/docs/redteam-implementation.md +++ b/docs/redteam-implementation.md @@ -272,7 +272,7 @@ completing the RT-4 suite and RT-11 tiers 1–2. - [x] rt-11-5 shows delivery metrics lighting up during the L2 kill (assert specific series non-zero), or files the observability gap. (landed with the #345/#339 fix: the scenario asserts `destTCP` Write/Dial errors ≥1 while dark and — shape A — `xtcp_tcp_dropped_total` ≥1; the silent window is now counted, verified both cycles) - [x] Phase 4 part 4 (conntrack leg): rt-11-6 **BLOCKED** (17/17, shape A `20261128T031048-c0f904e3d-3955865`; shape B 16/16 `20261127T232913-b7769a466-1209893`): the spray cannot stop reporting — established delivery immune, the re-dial races the slot leak and the #352 queue bounds the loss (both shapes green), no restart, polls never stop. The measured crossover is the ops view: a fresh scrape via docker-proxy needs a conntrack entry, so /metrics goes 000 while records flow — "absence of metrics must itself alert" confirmed end-to-end; harness lessons (mgmt-/24 NOTRACK, pgrep self-match, session-hold hang) encoded in-scenario. - [x] rt-11-7 **survives** (18/18, `20261129T091855-df22997b2-1827895`): a NET_ADMIN co-tenant builds pathological-but-legal own-netns state on the new locality deploy axis (`XTCP2_ENRICH=locality` — a rtnetlink listener inside every discovered netns); 87 links / 976 corpus neighbors / 1012 routes at the kernel's own extremes (15-char names, 255-char labels, metric 0/4294967295, 32-nexthop multipath, v6 zero-MAC), the listener parsed **+1141 corpus events live** and a forced ROUTE event re-dumped the full corpus (snapshot periodic 1→2) — no panic, no restart, scrape 200, catcher grew through the build. No fixture needed. Measured coverage finding: localityGroups excludes GroupNeigh — the deployed daemon never reads neighbor tables; the plan's "huge neighbor tables" leg was NOT exercised — the pathological-MAC corpus is kernel-resident only (a fixture seed for the day the enricher reads neighbors). Harness: dpkg-lock-era VM disk full (catcher 5.8 G + docker json logs 8.1 G) fixed at the source — common.sh truncates both at provisioning; xtcp2_deploy truncates BEFORE the tarball scp (a full disk killed the delivery itself); tcp-stress NUL-byte stdout capped (`--log-opt max-size`) — the work containers had filled 4.0 G each. -- [x] **Phase 4 part 4 complete (the churn/cgroup suite)**: rt-4-6 **BLOCKED** (16/16, `20261130T041837-848ebbe00-1287288` — 149 netns add+del cycles in 240 s, poll_sockets 237→7875, CPU 111–114% of 4 vCPUs, victim flowing MID-storm, `reconcile_incomplete` 0→0; post-storm convergence go_goroutines 51→51 / FDs 53→53 / poll_sockets 245 — no leak; **finding #370: netns add/del is invisible in metrics**, the per-poll reconcile drops its deltas, mapReconciler's stores/dels only fire on the 6 h ticker — measured via `reconcile/start` ~1/poll, not the run's original +14730 figure, which was the Deserialize/start series read through an ambiguous `variable="start"` match), rt-11-8 **BLOCKED** (18/18, `20261130T042718-848ebbe00-1464077` — 20 `docker restart` cycles each re-packing 10000 sockfill pairs (poll_sockets 241→20244): mid-storm victim lag 0 s, reconcile p99 0.00032 s, `add_rate`=0, no leak — self-churn does not even register; review correction: run 1's `add_rate`/`reconcile_incomplete` zeros were read through a broken msum — the awk `$1` escaped twice expanded locally to the series name, the syntax error hidden by `|| echo 0` — the fixed helper re-measures them), rt-4-8 **BLOCKED** (16/16, `20261130T045657-848ebbe00-1525702` — the refocused cgroup-cap variant, XTCP2_CPUS=2, both quota bounds derived from it: an admin TriggerPollBurst 120×1 s multiplies records 116→491 rec/s (~half the 1 s-floor ticker, half the burst — the total forced cadence) while CPU stays 130.9%/132.0% vs the 210% quota bound, RSS 24453→27002 kB, no OOM, metrics answers, rate settles once the poke counter proves burst completion (run 1 sampled mid-burst at ~3× the baseline, right at the old bound); the nuance: the forced cadence multiplies RECORDS not CPU — the record-volume residual is #342's family; prod guidance: pin XTCP2_CPUS). All three reviewed and fixed (the review caught four wrong-reason asserts; re-verified solo). The 24 h churn variant is env-gated (`RT_CHURN_SECS=86400 nix run .#redteam-rt-4-6`, never a matrix default) — the asserts are ratio/bound-based, the stores/dels check informational. +- [x] **Phase 4 part 4 complete (the churn/cgroup suite)**: rt-4-6 **BLOCKED** (16/16, `20261130T041837-848ebbe00-1287288` — 149 netns add+del cycles in 240 s, poll_sockets 237→7875, CPU 111–114% of 4 vCPUs, victim flowing MID-storm, `reconcile_incomplete` 0→0; post-storm convergence go_goroutines 51→51 / FDs 53→53 / poll_sockets 245 — no leak; **finding #370: netns add/del is invisible in metrics**, the per-poll reconcile drops its deltas, mapReconciler's stores/dels only fire on the 6 h ticker — measured via `reconcile/start` ~1/poll, not the run's original +14730 figure, which was the Deserialize/start series read through an ambiguous `variable="start"` match), rt-11-8 **BLOCKED** (18/18, `20261130T042718-848ebbe00-1464077` — 20 `docker restart` cycles each re-packing 10000 sockfill pairs (poll_sockets 241→20244): mid-storm victim lag 0 s, reconcile p99 0.00032 s, `add_rate`=0, no leak — self-churn does not even register; review correction: run 1's `add_rate`/`reconcile_incomplete` zeros were read through a broken msum — the awk `$1` escaped twice expanded locally to the series name, the syntax error hidden by `|| echo 0` — the fixed helper re-measures them), rt-4-8 **BLOCKED** (16/16, `20261130T045657-848ebbe00-1525702` — the refocused cgroup-cap variant, XTCP2_CPUS=2, both quota bounds derived from it: an admin TriggerPollBurst 120×1 s multiplies records 116→491 rec/s (~half the 1 s-floor ticker, half the burst — the total forced cadence) while CPU stays 130.9%/132.0% vs the 210% quota bound, RSS 24453→27002 kB, no OOM, metrics answers, rate settles once the poke counter proves burst completion (run 1 sampled mid-burst at ~3× the baseline, right at the old bound); the nuance: the forced cadence multiplies RECORDS not CPU — the record-volume residual is #342's family; prod guidance: pin XTCP2_CPUS). All three reviewed and fixed (the review caught four wrong-reason asserts; re-verified solo: rt-4-6 16/16 `20261130T215441-7b4e3808e-453165`, rt-11-8 18/18 `20261130T220551-7b4e3808e-718451`, rt-4-8 17/17 `20261130T221109-7b4e3808e-764112`) and then the full matrix re-run: **38/38 PASS, 0 failed** on the branch head `8a2d69078` (matrix run `20261201T000311-8a2d69078`). The 24 h churn variant is env-gated (`RT_CHURN_SECS=86400 nix run .#redteam-rt-4-6`, never a matrix default) — the asserts are ratio/bound-based, the stores/dels check informational. - [x] **Task 4.11 wrap-up (the observability enabler)**: of the four gauges the suite needs, three already exist and are now asserted in-scenario — FD usage (`process_open_fds`, the standard collector), goroutines (`go_goroutines`), poll-cycle duration (`Poller/pollToDoneDuration` + `PollTimeout`), delivery errors (`destTCP/Write/error`, `destS3Parquet/upload/error`, `Poller/envelopeFlush/error`); per-namespace coverage lag does NOT exist (aggregate-only) — filed as **#371**; the NEW measured gap — netns churn invisibility — filed as **#370** (the per-poll reconcile's add/del deltas are dropped). - [ ] Every scenario traps cleanup; a final "victim still reporting" assertion runs after each attack (the RT-11 invariant). - [ ] The wire-the-limits issue (max_connections/accept-rate) has measured evidence attached.