Skip to content

redteam: Phase 3 (part 2) — poll-frequency DoS, envelope extremes; rt-7-4 already gated - #318

Merged
randomizedcoder merged 5 commits into
mainfrom
redteam/phase3-part2
Nov 24, 2026
Merged

randomizedcoder merged 5 commits into
mainfrom
redteam/phase3-part2

Conversation

@randomizedcoder

Copy link
Copy Markdown
Owner

What

Phase 3 part 2 of docs/redteam-plan.md: the admin-abuse rows that need no new fixtures (part 1 = #317; part 3 = the Garage rows, deferred).

Scenarios (findings.md rows, evidence in every run)

  • rt-3-3 poll-frequency CPU DoS — CONFIRMED (S3): SetPollFrequency to 1s/500ms + poll-burst (60 polls, 1 s apart — the server validates the interval ≥ 1 s): record rate 50/s → 180/s (3× amplification — records/s track the attacker's cadence), CPU 124% → 130%, RSS ~27 MiB, no wedge (metrics 200, catcher flowing). Amplification is bounded by the poll rate at this shape — a fleet host's namespace/socket load multiplies it. Restored + final Get.
  • rt-3-4 envelope extremes — CONFIRMED (S3): SetEnvelopeFlush accepts the uint32 max (4 GiB / 4294967295 rows — no upper-bound validation); RSS 26.1 → 27.2 MiB over 40 s (+1 MiB, linear in records at this shape's rate), no instant OOM — the cap is the ceiling, the record rate is the brake, the cgroup limit is the only ceiling. Restored to the defaults (786432/10000) + final Get.
  • rt-7-4 — already covered upstream (plan row amended): checks.govulncheck exists in the flake (hermetic, pinned vuln DB — green) and govulncheck-fresh runs the live database (0 reachable findings; 1 required-module vulnerability not called by code). The plan's 'no govulncheck gate today' premise was stale — no scenario written.

Remaining in Phase 3 (part 3)

rt-3-2 (S3 exfil — needs the Garage fixture), rt-7-1/7-2/7-3 (artifact bombs — Garage).

…es, govulncheck already gated

rt-3-3 poll-frequency CPU DoS (CONFIRMED): SetPollFrequency to 1s/500ms
+ poll-burst — 3x record amplification (50/s -> 180/s; records/s track
the attacker's cadence), CPU 124% -> 130%, RSS ~27MiB, no wedge
(metrics 200, catcher flowing), restored + final Get. The server caps
the burst interval at >= 1s (validated).

rt-3-4 envelope extremes (CONFIRMED): SetEnvelopeFlush accepts the
uint32 max (4 GiB / 4294967295 rows — no upper-bound validation); RSS
26.1 -> 27.2MiB over 40s (+1MiB, linear in records at this shape's
rate), no instant OOM — the cap is the ceiling, the record rate is the
brake, the cgroup limit is the only ceiling. Restored to the defaults
(786432/10000) + final Get.

rt-7-4 already covered upstream (plan row amended): checks.govulncheck
exists (hermetic, pinned vuln DB — green) and govulncheck-fresh runs
the live database (0 reachable findings; 1 required-module
vulnerability not called by code). The plan's 'no gate today' premise
was stale — no scenario written.

Deferred (part 3): rt-3-2 (S3 exfil), rt-7-1/7-2/7-3 (artifact
bombs) — both need the Garage fixture.
…ot CONFIRMED

The full-matrix run flaked rt-3-4's growth assert (RSS 26.89 -> 26.82 —
the run-1 '+1MiB' was RSS jitter, not growth). The plan row's expected
column is 'no unbounded growth under admin-set extremes' — the observed
stable RSS IS the defense holding: the envelope flushes on the poll
cycle, so the uint32-max caps are a flush ceiling, not a growth driver.
The scenario now asserts the no-growth outcome (EXPECT=BLOCKED, the
growth pin kept so a flush regression flips it); findings + DoD rows
amended.
@randomizedcoder

Copy link
Copy Markdown
Owner Author

Added the fix commit: the first full-matrix run flaked rt-3-4's growth assert — the run-1 '+1 MiB' was RSS jitter, not growth. The plan row's expected column is 'no unbounded growth under admin-set extremes', and the observed stable RSS is the defense holding (the envelope flushes on the poll cycle; the uint32-max caps are a flush ceiling, not a growth driver). rt-3-4 is now EXPECT=BLOCKED with the growth pin kept so a flush regression flips it.

redteam-matrix re-run after the fix: 18 scenarios, 0 failed (~55 min).

The rt-3-3 red-team scenario measured the poll loop's amplification:
records/s track the poll cadence (50/s -> 180/s at 1 s + bursts), so a
sub-second cadence is a CPU/output amplifier an admin credential can
drive on demand. The floor bounds it.

poll_frequency now validates gte 1s in the proto — on BOTH XtcpConfig
(the startup -frequency flag and the Set/reconfigure path) and
SetPollFrequencyRequest (the RPC) — aligned with the existing
TriggerPollBurst.interval floor, so the codebase tells one story: xtcp2
honors no cadence faster than 1 second. The proto validation is the
constant; it is enforced at all three entry points:

  - startup: -frequency 500ms -> exit 64 ('poll_frequency: must be
    greater than or equal to 1s and less than or equal to 604800s')
  - reconfigure (Set): the XtcpConfig validation rejects the change
  - SetPollFrequency: InvalidArgument

The harness's own shapes stay legal (2s/1s default, the 1s/500ms
attack shape at the floor). Small-socket hosts that want fast polling
keep the full 1 s-7 days range; the proto's recommendation comment
(30 s or 60 s) stands.

Verified: TestConfigService_SetPollFrequency_floor (0 and 500 ms
rejected, the 1 s floor accepted); the full pkg/xtcp + cmd test
suites; go-vet, golangci-lint (quick + comprehensive) green. The
red-team scenario pins the fix: rt-3-3 asserts the 500 ms rejection
(the amplification bound) and the amplification at the floor — a floor
regression fails the scenario in CI. security.md's Resource
protections section documents the floor.
@randomizedcoder

Copy link
Copy Markdown
Owner Author

The mitigation for rt-3-3's amplification finding: poll_frequency is now floored at 1 s, the fastest honored cadence, in the proto itself (both XtcpConfig and SetPollFrequencyRequest — aligned with the existing TriggerPollBurst.interval floor, so the codebase tells one story). The proto validation rule is the constant, enforced at all three entry points: the startup -frequency flag (500 ms → exit 64), the Set/reconfigure path, and SetPollFrequency (InvalidArgument).

The scenario now pins both sides — the 500 ms rejection (a floor regression fails CI) and the amplification at the floor (49 → 178 records/s at 1 s, healthy throughout, restored + final Get). Small-socket hosts keep the full 1 s–7 days range; the proto's 30–60 s recommendation stands.

Non-goal (noted for a follow-up if wanted): a poll_timeout floor — with frequency ≥ 1 s and the CEL timeout < frequency, the timeout can still be set to a few ms, which truncates dumps (an operational footgun, not an amplifier — the poller's serialized loop bounds the work either way).

…oor value

The proto floor (poll_frequency gte 1s, enforced by protovalidate at the
startup flag, the Set/reconfigure path, and SetPollFrequency) is the
primary. This adds the Go belt at the exact moment the timer gets set,
so the invariant holds even if the rule regresses or a future caller
skips validation:

- xtcp.MinPollFrequency (pkg/xtcp/poller.go) — 1 s, the fastest poll
  cadence the poller honors.
- computePollInterval clamps EVERY tick interval to the floor — the
  single choke point both timer-set sites share. That also covers three
  edges the proto rule cannot reach: the 0/negative durations that used
  to PANIC ticker.Reset (the old test comment: 'the production poller
  doesn't validate the duration either' — a daemon crash, now a slow
  tick), a sub-second change-channel value (silently accepted before),
  and a 100% poll_jitter_pct draw (which halves the interval to 500 ms
  at a 1 s frequency — the effective cadence could sit under the floor).
- handleChangePollFrequency floors explicitly BEFORE the Reset and
  counts the clamp (xtcp_counts{function=Poller,variable=ticker.Floored})
  so a sub-floor write is visible in metrics, not just silently clamped.

Tests: TestHandleChangePollFrequency_floor (the 5 ms clamp -> Floored +
Reset counters; the floor value itself is not a sub-floor), the
panic-codifying table rows flip to floor-codifying (0/negative/1 ns all
reset at the floor, no panic), TestComputePollInterval gains the freq==0
-> floor and the 100%-jitter-halves-1s -> floor rows, and
TestComputePollInterval_floorRealJitter pins 2000 real jitter draws on a
floor-value frequency at >= 1 s. Full pkg/xtcp suite green; go-vet +
golangci-lint-quick green.
@randomizedcoder

Copy link
Copy Markdown
Owner Author

Both questions answered in code (two new commits):

1. Do we definitely call .Validate() on the proto at every entry? Yes — verified in code, not just empirically:

  • Startup flags: runMain → protovalidate.Validate(c) (xtcp2.go:1221) → exit 64.
  • Soft-restart env carry: startupConfig loads the carried config FIRST (c = envc), then the same runMain validation runs — the re-exec child revalidates before anything binds.
  • ConfigService.Set (reconfigure): protovalidate.Validate(in.Config) (grpc_configService.go:162).
  • SetPollFrequency: protovalidate.Validate(in) (line 333) — and the other config RPCs validate their own requests (TriggerPollBurst, SetS3Upload, SetEnvelopeFlush).

2. The Go-side belt at the timer — yes, and it caught three real holes. The existing test literally documented the gap: "the production poller doesn't validate the duration either" — ticker.Reset PANICS on 0/negative. The belt:

  • xtcp.MinPollFrequency = 1 * time.Second (pkg/xtcp/poller.go).
  • computePollInterval clamps every tick interval — the single choke point both timer-set sites share. This also fixes: (a) the 0/negative panic (a daemon crash → a slow tick), (b) sub-second change-channel values (silently accepted before), (c) a 100% poll_jitter_pct draw, which HALVES the interval (500 ms effective cadence at a 1 s frequency — under the floor even with the proto rule intact).
  • handleChangePollFrequency floors before the Reset and counts the clamp (xtcp_counts{function=Poller, variable=ticker.Floored}) so a sub-floor write is visible in metrics.

Tests: the panic-codifying rows flip to floor-codifying (0/1 ns/5 ms/negative all reset at the floor, no panic), a dedicated TestHandleChangePollFrequency_floor (the clamp counter + the floor value itself is not a sub-floor), and 2000-draw real-jitter pins at ≥ 1 s. Full pkg/xtcp suite green; go-vet + golangci green.

@randomizedcoder
randomizedcoder merged commit fab0e42 into main Nov 24, 2026
1 check passed
@randomizedcoder
randomizedcoder deleted the redteam/phase3-part2 branch November 24, 2026 00:32
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