Skip to content

redteam: Phase 4 part 4 — churn/cgroup suite (rt-4-6, rt-11-8, rt-4-8) + task 4.11 wrap-up - #372

Merged
randomizedcoder merged 7 commits into
mainfrom
feat/redteam-rt-4-6-rt-11-8
Dec 1, 2026
Merged

randomizedcoder merged 7 commits into
mainfrom
feat/redteam-rt-4-6-rt-11-8

Conversation

@randomizedcoder

@randomizedcoder randomizedcoder commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Closes Phase 4: the three remaining rows plus the observability-enabler wrap-up. All three scenarios pass in one run each; two product issues filed from the measurements (#370, #371).

rt-4-6 namespace/socket churn storm — BLOCKED (16/16, 20261130T041837-848ebbe00-1287288)

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):

  • No leak, measured by convergence, not fixed sleeps: go_goroutines 51→51, process_open_fds 53→53 (run 1 measured the transient: +15 at 30 s settled to baseline−1 by 4 min, flat — in-flight dump/flush goroutines, not a leak; the asserts now wait up to 180 s for the bound)
  • The netns map drained, proven by the socket gauge: poll_sockets 237→7875 mid-storm → 245 post-storm (a leaked dead netns counts as unknown = −maxRecordsPerNetns = 1M sockets in the gauge)
  • CPU bounded (111–114% of 4 vCPUs), victim records flowing MID-storm, reconcile_incomplete_total 0→0, no restart
  • The 24 h variant is env-gated (RT_CHURN_SECS=86400), never a matrix default; all asserts duration-agnostic
  • Vantage stated in-row: the storm runs host-side (the fleet-operator position — a PLAIN attacker cannot create netns; NET_ADMIN does not grant it either, the rt-11-7 ladder)

rt-11-8 self-churn + reconcile amplification — BLOCKED (18/18, 20261130T042718-848ebbe00-1464077)

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 3000× above — the scan is over ~8 netns; the restart churn is noise to it)
  • Post-storm: goroutines 51→51, FDs 53→53, poll_sockets 250 (map drained), netns_dropped{add_rate}=0, reconcile_incomplete=0, no restart

rt-4-8 poll amplification under a CPU quota — BLOCKED (16/16, 20261130T045657-848ebbe00-1525702)

The premortem-refocused cgroup variant (the 100-container population was arithmetic — rt-3-3 measured the mechanism; this row's untested clause was cgroup protection). XTCP2_CPUS=2 (the deploy axis), admin vantage (TriggerPollBurst is an admin RPC):

  • SetPollFrequency to the 1 s floor, TriggerPollBurst 120×1 s (returns immediately; the daemon drives the spacing; the 500 ms timeout set first so the 1 s interval passes the interval > poll_timeout validation)
  • The quota holds the line: record rate 116→491 rec/s (4.2×, the full-dump-per-poll cost) while daemon CPU is 130.9%/132.0% vs the 210% quota bound (NanoCpus=2000000000 asserted on the container), RSS 24453→27002 kB, no OOM-kill, metrics answers through the burst, rate settles post-burst, no restart
  • The nuance: at this population the burst multiplies RECORDS, not CPU (116→131% CPU for 4.2× records — polling is cheap); the record-volume residual is rt-4-1: the attack's own sockets are reported — ~4K idle conns amplified record volume ~149x #342's family (the burst's own -count bounds it). Prod guidance: pin XTCP2_CPUS — the default deploy is unlimited.

Task 4.11 (observability enabler) — 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, and the delivery-error counters. Two issues filed:

Evidence

Gates: nix run .#redteam-lint 0 findings; nix build .#checks.x86_64-linux.lint-baseline exit 0. Scenario runs: rt-4-6 16/16, rt-11-8 18/18, rt-4-6 run 1: 14/15 (the +15 goroutines at the 30 s settle was the measured transient that motivated the convergence waits), run 2: 16/16, and a review-driven re-verification after the four script fixes: 16/16. The 36-scenario full-matrix regression runs before merge.

…-8, rt-4-8), task 4.11 wrap-up

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.
…rt race, not a product change)

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 df22997 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).
@randomizedcoder

Copy link
Copy Markdown
Owner Author

Full-matrix regression: 38 scenarios, 37 PASS + 1 assert race fixed + re-verified solo.

The one failure was rt-11-5 ok 14 (cycle 2, "no new Write errors during the second stall"): 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.go/destinations_queue.go untouched between df22997b2 and this branch).

Fixed in 3a8f41cc9 by mirroring cycle 1's shape treatment: the error window widens first (poll Write/error up to 60 s while the poison is active), then a third ok shape covers the backoff — gated on the block's own evidence (polls kept issuing, asserted in the same branch; delivery heals on de-poison, ok 17). 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.

Re-verified: 18/18 PASS twice (20261130T105600-d60b20007-3991909 — errors in-window 11→13; 20261130T111556-d60b20007-4167647 — the fix on the branch head, errors 9→12).

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.
…e of 120)

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).
@randomizedcoder

Copy link
Copy Markdown
Owner Author

Thank you — all eight points confirmed against the code and fixed in 9d11db7a0/7b4e3808e, and the three scenarios re-verified solo. No product code is at fault; every issue was a scenario script bug or a mis-claimed metric.

1. rt-11-8 msum always 0 — confirmed and fixed. The awk program sat inside a double-quoted string carrying \\$1 (escaped twice), so $1 expanded locally to the series substring and awk got a syntax error that || echo 0 hid as a permanent 0 — add_rate and reconcile_incomplete could not fail, and run 1's zeros were never measured. Fixed to the single escape (rt-4-6's copy was correct); the helper now documents the trap. Re-verified 18/18 (20261130T220551-7b4e3808e-718451): add_rate=0 and incomplete=0 as measured values this time, reconcile p99 0.00147 s, FDs 53→53.

2. rt-4-6 read Deserialize/start, not reconcile/start — confirmed live and fixed. A live scrape shows NINE series with variable="start"; sorted first is Deserialize/start (227550 at that moment — the envelope-deserialization counter, ~60/s, exactly the run's +14730), while reconcile/start was 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 (measured: delta 130 ≈ 1/poll over the storm window, baseline read right after deploy at 26). Stores/dels likewise now match function="mapReconciler". #370's quoted "+14730" gets a correction comment — the issue's core claim (stores/dels 0, per-poll deltas dropped) is unaffected: the live scrape independently showed mapReconciler stores/dels = 0.

3. The "map drained via poll_sockets" claim was wrong twice — corrected. The sockstat fd keeps its namespace alive (sockstat.go:14-18), so a leaked entry keeps reading ~0 sockets and never reads "unknown"; and -maxRecordsPerNetns is 262144 (1<<18), not 1M. The FD convergence check is the drain proof (a leaked entry = one leaked fd) — the scenarios now say exactly that, and the socket gauge claims only "no residual sockets". Fixed in both churn scenarios + findings + plan + implementation.

4. rt-4-8's "post-burst" sample was mid-burst — fixed with the daemon's own completion view. pollBurstRunner pokes on its own 1 s cadence for -count seconds and SetPollFrequency does not stop it, so the run-1 sample ~40-52 s in sat at the restored 2 s ticker + 1 s burst ≈ 1.5 polls/s = 3× the 0.5/s baseline, right at the old bound. The scenario now restores first, then wait_fors the poke counter (pollBurstRunner poke+pokeDropped ≥ 120 — poke alone can stall when a poke is subsumed by an already-queued poll, pokeDropped is not a completion failure), and only then samples; the settle bound tightens to 2×. Re-verified 17/17 (20261130T221109-7b4e3808e-764112): baseline 171 → mid-burst 583 rec/s → post-burst 189 rec/s (run 1's "344 settling" was the mid-burst artifact). The attribution is corrected everywhere too: ~half the 4.2× is the 1 s-floor ticker SetPollFrequency set, half the burst — the daemon runs both.

5. stores=0 && dels=0 was a pass-on-bug — made informational. A 24 h soak sees the 6 h ticker fire (stores/dels > 0) and the day #370 lands the per-poll deltas become counted — neither is a failure of this row. The check is now two informational shapes, and "all asserts duration-agnostic" is corrected to "ratio/bound-based + the stores/dels check informational".

6. rt-4-8's hard-coded 2-CPU bounds — worked out from XTCP2_CPUS. NanoCpus asserts exact equality with $XTCP2_CPUS * 1e9, and the CPU bound is $XTCP2_CPUS * 100 + 10.

7. rt-11-5's placeholder run ID — now cites the real matrix run (20261130T064858).

8. Cleanup traps added to all three churn scenarios (and rt-4-8 restores the poll cadence): a set -e death (e.g. a wait_for timeout) previously exited before teardown, leaving the churn driver, the sockfills, or the 1 s floor running on the victim VM. The traps are idempotent and registered before the drivers launch; finish()'s exit fires them on both exit codes.

Also from the re-runs: rt-4-6's cycle-count gate was itself miscalibrated — the driver cadence is 1.6–2.4 s/cycle (docker rm/run + sleep 1, each container packing 2500 LISTEN + 2500 dials), so 240 s yields 101–149 cycles and the old ≥120 bound failed a healthy run (101 cycles, every product assert green); now /3. Re-verified 16/16 (20261130T215441-7b4e3808e-453165).

Gates on the merged tree (origin/main at defa100c8): nix run .#redteam-lint OK, nix build .#checks.x86_64-linux.lint-baseline exit 0. The 38-scenario full-matrix regression is running now; the result posts here before merge.

@randomizedcoder

Copy link
Copy Markdown
Owner Author

Full-matrix regression: 38 scenarios, 0 failed — all green on the branch head 8a2d69078 (post-review fixes), the body's "runs before merge" commitment now satisfied.

Every scenario PASS: rt-4-6 16/16, rt-11-8 18/18, rt-4-8 17/17, rt-11-5 MITIGATED 18/18 (the backoff shape from the first matrix run held — cycle 2 errored in-window this time), and the 34 previously-verified rows unchanged.

For the review record, the four script bugs are all fixed and re-measured on this exact tree: rt-11-8's msum now sums real values (add_rate=0, incomplete=0 as measurements), rt-4-6 reads reconcile/start via its full label set (delta ≈ 1/poll; the +14730 was Deserialize/start — correction also posted on #370), rt-4-8 samples post-burst only after the poke counter proves completion (post-burst 189 rec/s vs the mid-burst 344 artifact), and the "map drained" claim is attributed to the FD convergence with the sockstat-fd/262144 correction everywhere it was repeated.

@randomizedcoder
randomizedcoder merged commit aa5f97b into main Dec 1, 2026
1 check passed
@randomizedcoder
randomizedcoder deleted the feat/redteam-rt-4-6-rt-11-8 branch December 1, 2026 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant