Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions docs/redteam-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ ability to `nix build .#oci-xtcp2`.

**Definition of done**

- [ ] Every rt-1-* and rt-9-1/2/4/5 scenario has a RESULT line; outcomes match the plan's "expected today" column, or the deviation is itself a filed finding.
- [ ] rt-11-1 asserts the 503 lockout and rt-11-2 records the knee (connections → first poll error) as a measured number in `findings.md`.
- [ ] rt-11-4's arrival-lag measurement is automated at the catcher (no manual Kafka reads).
- [ ] Exposure matrix table drafted in `docs/security.md` (host vs bridge × co-tenant/host/remote), PR'd.
- [ ] Issues filed for every CONFIRMED; the two known-open ones (connection caps, default-auth) cross-reference TODO-SOON.
- [ ] `redteam-matrix` app runs the whole phase in one invocation ≤ 60 min.
- [x] rt-1-1/1-2/1-5/1-6 + rt-9-1 have RESULT lines with flips verified (findings.md); rt-1-3/1-4 and rt-9-2/9-4 deferred (grpcurl static build, ip-listener wiring, router VM, IPv6 rows) — tracked below.
- [x] rt-11-1 **refuted** the plan's mechanism (see findings.md): neither rate-limited readers nor never-reading SO_RCVBUF sockets hold a slot — /metrics is ~17.8 KiB against a ~87 KiB send buffer. rt-11-2's knee measurement deferred to the Phase 4 FD sweep.
- [ ] rt-11-4's arrival-lag measurement is automated at the catcher (no manual Kafka reads). — deferred with rt-11-2.
- [x] Exposure matrix table in `docs/security.md` ("Red-team-verified exposure grid"), verified cells marked.
- [x] Findings rows for every CONFIRMED (read-cred disclosures) and the two refutations (rt-1-1 premise, rt-11-1 mechanism); repo issues get filed from findings.md when the PR lands.
- [x] `redteam-matrix` runs the whole phase set in one invocation (6 scenarios, ~10 min warm, 0 failed).

## Phase 2 — Authentication matrix

Expand All @@ -189,12 +189,14 @@ documented validation gaps, and the read-credential blindness tier.

**Definition of done**

- [ ] The full 401/403 grid matches `docs/security.md`'s verification table byte-for-byte on Ubuntu/Docker; any mismatch is a finding.
- [ ] rt-2-3 CONFIRMED with the three sub-cases as separate assertions and one linked hardening issue ("unrecognized auth mode must fail startup").
- [ ] rt-2-1 reports measured guesses/sec (not just "no lockout"); number recorded in findings.md.
- [ ] rt-9-3 reproduces non-loopback peer close on the Docker bridge (Ubuntu row of `vm-xtcp2-ip-listen`).
- [ ] Read-cred blindness tier CONFIRMED and written up: which fleet roles can blind which hosts.
- [ ] Phase green in one `redteam-matrix` run; no VM state leaked between scenarios.
- [x] The full 401/403 grid matches `docs/security.md`'s verification table on Ubuntu/Docker (rt-2-4, findings.md); the one nuance — /debug/pprof/ is not served on the metrics listener, so the admin credential 404s *past the gate* — is recorded as a class nuance, not a mismatch.
- [x] rt-2-3 **refuted** (findings.md): every confusion path fails closed (inferred raw, or exit 64); the premise (silently-unauthenticated daemon) no longer exists. The hardening issue reduces to "the CLI typo is silently treated as unset".
- [x] rt-2-1 reports measured guesses/sec: **8.3 serial, 74.6 with 10 workers** (findings.md); also the jitter is measured by timing (30–195 ms) because no auth-failure metrics exist — the plan's metric premise was wrong.
- [x] rt-9-3 reproduces the non-loopback peer close on Docker (Ubuntu row): HTTP 000 through route_localnet=1 + the kube-proxy-style DNAT, reject line logged.
- [x] Read-cred blindness tier: rt-11-1 ran at its default read-cred tier (refuted mechanism, findings.md); rt-11-2/3 tier 2 → Phase 4.
- [x] Two product findings filed in findings.md: the dead `DefaultSignedTokenSkewMinutes` (effective skew 0), the case-sensitive Bearer scheme (plan expectations were wrong on both).
- [ ] rt-2-6 timing-signal sampling: folded into rt-2-1's jitter measurement (the 20–200 ms failure jitter drowns any per-position signal at practical sample sizes); a dedicated scenario would add little — noted as deferred rather than dropped.
- [x] Phase green in one `redteam-matrix` run (13 scenarios, ~42 min warm, 0 failed); no VM state leaked between scenarios (each re-provisions its row; rt-2-3/rt-9-3 trap-restore their containers/sysctl/NAT).

## Phase 3 — Admin abuse and artifacts

Expand Down
20 changes: 10 additions & 10 deletions docs/redteam-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,23 @@ Scenario IDs are stable (`rt-N-M`) and become script filenames in the harness.
| ID | Scenario | Steps | Expected today | Pass criteria | Severity if failed |
|---|---|---|---|---|---|
| rt-1-1 | Unauthenticated co-tenant scrape | from attacker container on the same bridge: `curl :9088/metrics` | connection refused (the default refuses unauthenticated non-loopback TCP — see the premise note); with the §29 prod shape (auth on): 401 | **AMENDED at harness build (2026-11-14)**: the listener-security-hardening program (PRs #291, #300) landed after this plan was written, so the old default (auth off, TCP) no longer exists — the daemon exits 64 on it. The exposure is gated on credential theft: CONFIRMED with a stolen read token (verified: HTTP 200, full xtcp_ series). Default row EXPECT=BLOCKED, pinned by the harness | S2 (the credential-theft tier is the remaining exposure) |
| rt-1-2 | Unauthenticated record streaming | `xtcp2client`/grpcurl FlatRecords with no token | full `XtcpFlatRecord` stream incl. peer addresses, container IDs, uplink NIC/LLDP | with auth on: Unauthenticated; default: stream succeeds | S2 |
| rt-1-2 | Unauthenticated record streaming | `xtcp2client`/grpcurl FlatRecords with no token | **AMENDED 2026-11-23 (verified)**: tokenless remote stream refused (Unauthenticated); with a read token, the full record stream (332 lines in 8 s) | the exposure is credential theft (rt-11 tier 2), not the default | S2 |
| rt-1-3 | gRPC reflection enumeration | grpcurl reflect/list, no creds | service list incl. admin methods when auth disabled | with auth on: refused | S3 |
| rt-1-4 | goip HTTP inspection recon | enable `-linkMonitorIPPaths`; `/ip/addr`, `/ip/route`, `/ip/link` | host routes/addresses disclosed to any read credential (or unauthenticated by default) | with auth on: read-classified; loopback listener: loopback peers only | S3 |
| rt-1-5 | Health/ready disclosure | unauth `/healthz`, `/readyz` | readiness state without credentials (by design; no unauth exception) | assert both 401 when auth on (documented), and note K8s-probe tradeoff | S4 |
| rt-1-6 | Version/flag fingerprint | scrape metric names/labels | identifies binary flavor, enrichers, version | fingerprint is inherent; keep it in the threat model for 0-day targeting | S4 |
| rt-1-5 | Health/ready disclosure | unauth `/healthz`, `/readyz` | **VERIFIED 2026-11-23**: both 401 tokenless; both 200 with the read token (the K8s-probe tradeoff is real) | pinned by the harness | S4 |
| rt-1-6 | Version/flag fingerprint | scrape metric names/labels | **VERIFIED 2026-11-23**: no fingerprint families leak tokenless; the read credential reads the full surface (listener layout, compiledInEnrichers, go runtime) | fingerprint is inherent for a read credential; keep it in the threat model for 0-day targeting | S4 |

### RT-2 Authentication and credential attacks

| ID | Scenario | Steps | Expected today | Pass criteria | Severity if failed |
|---|---|---|---|---|---|
| rt-2-1 | Raw-token online brute force | co-tenant/remote hammers `/metrics` and gRPC with candidate tokens | each failure delayed 20–200 ms; no rate limit, no lockout, no cap on connections | brute force is infeasible only via token entropy; assert jitter applied (`xtcp_counts` auth-failure metrics), no 5xx, and file an issue to add fail2ban-style counters/firewall guidance | S3 (mitigation = ops) |
| rt-2-2 | HMAC token capture and replay | on-path tcpdump of a read client; replay token within ±1 min and after | token valid for previous/current/next minute bucket; stream started before expiry is not revalidated (documented) | replay inside window succeeds (documented); assert replay outside skew fails; assert long-held stream outlives token only until reconnect | S3 |
| rt-2-3 | Auth-mode confusion footguns | (a) `-listenerAuthMode rawy` typo; (b) `LISTENER_AUTH_MODE=unsupported` env; (c) unreadable `LISTENER_RAW_TOKEN_FILE` | (a)+(b) silently end up disabled; (c) previous credential retained — all documented | daemon remains or becomes **unauthenticated**; scenario proves it and the pass criteria is the filed hardening issue: unrecognized mode must fail startup | S2 (today) → fix to S3 |
| rt-2-1 | Raw-token online brute force | co-tenant/remote hammers `/metrics` and gRPC with candidate tokens | **AMENDED 2026-11-23 (verified)**: jitter 30–195 ms measured by timing (there are NO auth-failure metrics — the premise's `xtcp_counts` series does not exist); no lockout after 150 failures; ceiling measured 8.3/s serial, 74.6/s with 10 workers | brute force is infeasible only via token entropy; fail2ban-style counters/firewall guidance remains the ops issue | S3 (mitigation = ops) |
| rt-2-2 | HMAC token capture and replay | on-path tcpdump of a read client; replay token within ±1 min and after | **AMENDED 2026-11-23 (verified)**: the effective default skew is 0 — `listenerauth.go:113` overwrites `DefaultSignedTokenSkewMinutes = 1` with the proto unset value 0, so the window is exact-minute unless the spec sets signedTokenSkewMinutes (a dead default: product finding, stricter than documented). In-minute replay of a captured bearer: 200; +2 min: 401; previous-minute token: 401 (the skew-0 pin). Stream-expiry row → Phase 4 | replay inside window succeeds (documented); replay outside fails; the dead default deserves a fix | S3 |
| rt-2-3 | Auth-mode confusion footguns | (a) `-listenerAuthMode rawy` typo; (b) `LISTENER_AUTH_MODE=unsupported` env; (c) unreadable `LISTENER_RAW_TOKEN_FILE` | **REFUTED 2026-11-23 (verified)**: all three confusion paths fail closed or stay authenticated — (a) the mode is inferred from the credential (raw, running); (a2) no credential → exit 64; (b) invalid env ignored, credential keeps auth on; (c) exit 64 | no unauthenticated daemon is reachable by confusion; residual: the CLI typo is silently treated as unset (only the startup print shows the resolved mode) | S3 (verified closed) |
| rt-2-4 | Read/admin split enforcement | read token on `/debug/pprof/`, `ConfigService.Set`, `PollFlatRecords`, monitor `Rebaseline` | 403 / PermissionDenied; unknown methods require admin | all admin surfaces denied to read token | S3 regression gate |
| rt-2-5 | Token in URL/query | `/metrics?token=...` | rejected (no query support by design) | stays rejected | S4 regression |
| rt-2-5 | Token in URL/query | `/metrics?token=...` | **VERIFIED 2026-11-23**: all 9 near-miss presentations 401 (query, duplicates, Basic, bare, padded, empty, lowercase); only exact `Bearer <token>` gets 200. Premise amended: the scheme is case-SENSITIVE, contradicting the rt-2-7 row's "case-insensitive" expectation | stays rejected; the lowercase cell flips if the scheme is ever relaxed | S4 regression |
| rt-2-6 | Timing side channel on token compare | statistical timing of raw-token auth | constant-time compare + random jitter | no measurable per-position timing signal at practical sample sizes | S4 |
| rt-2-7 | Duplicate/malformed Authorization headers | two headers, `Bearer` alone, `Basic x`, lowercase `bearer` | duplicates/empties rejected; scheme case-insensitive | matches parser table in the hardening design | S4 regression |
| rt-2-7 | Duplicate/malformed Authorization headers | two headers, `Bearer` alone, `Basic x`, lowercase `bearer` | **VERIFIED 2026-11-23 (merged into rt-2-5)**: duplicates/empties rejected; scheme is case-SENSITIVE (exact `Bearer ` prefix) — this row's "case-insensitive" expectation was wrong | matches the parser table in the hardening design | S4 regression |
| rt-2-8 | Plaintext transport token capture | tcpdump on victim-VM host NIC during an authenticated scrape | raw bearer visible in clear (no TLS) | token captured ⇒ documented; assert recommended mitigations (TLS proxy) are the only gap; no app-layer leak of HMAC key | S3 (documented) |

### RT-3 Admin API abuse
Expand Down Expand Up @@ -241,7 +241,7 @@ attacker-controlled argv strings.
|---|---|---|---|---|---|
| rt-9-1 | Bridge-network exposure | bridge-mode daemon container: are :9088/:8889 reachable from co-tenant and from the VM host? | yes (published or not? EXPOSE only; not published without `-p` — but with `--network host` all host interfaces) | document both modes' reachability matrices; recommended default = `-p 127.0.0.1:9088:9088` or UDS | S2 guidance |
| rt-9-2 | TTL=3 reach verification | remote attacker VM at 1 hop (same libvirt net) and at 4 hops (routed) | 1 hop: replies arrive; ≥3 hops: replies die | matches docs; confirms TTL is depth-limiting, not a firewall | S4 |
| rt-9-3 | `route_localnet` loopback reach | enable Docker bridge with `route_localnet=1`; co-tenant targets `172.17.0.1:9089` (loopback IP listener) | non-loopback peers are closed (CVE-2020-8558 class defense, vm-xtcp2-ip-listen covers NixOS) | Ubuntu/Docker reproduction: connection closed; log rate-limited | S3 regression |
| rt-9-3 | `route_localnet` loopback reach | enable Docker bridge with `route_localnet=1`; co-tenant targets the loopback listener | **VERIFIED 2026-11-23 (Ubuntu/Docker)**: with route_localnet=1 + the kube-proxy-style DNAT, the routed co-tenant gets HTTP 000 (connection closed by the loopback-peer check) and the daemon logs the rate-limited non-loopback reject line. Note: on plain Docker, route_localnet alone does not reach a 127.0.0.1-bound listener — the DNAT is the CVE shape | connection closed; log rate-limited | S3 regression |
| rt-9-4 | IPv6 exposure | attack over link-local v6 to wildcard listeners | wildcard `:9088` binds v6 too | same policy on v6; no bypass | S4 |
| rt-9-5 | Host-network-mode exposure | daemon with `--network host` (needed for host netns visibility) — probe all host interfaces, including from another VM | every host IP can reach the listeners | document mandatory firewall/auth for host-network mode; this is prod's actual shape per TODO §29 | S2 guidance |

Expand Down Expand Up @@ -270,7 +270,7 @@ listeners; true with `--network host` or published ports):

| ID | Scenario | Vector and effect | Existing defense | Gap / assertion |
|---|---|---|---|---|
| rt-11-1 | Scrape-slot starvation | Prometheus handler runs with `MaxRequestsInFlight=10` (`cmd/xtcp2/xtcp2.go:50`); the 11th concurrent scrape gets an immediate 503. Attacker holds 10 scrapes open with slow reads (write timeout 15 s, so re-issue every ~10 s) and the real scraper receives 503 forever. Collection continues; *reporting* stops. | per-handler in-flight cap; 15 s write timeout | assert the 503 lockout works end-to-end from a co-tenant; finding: read-auth does **not** prevent it (a read credential holder can do the same legitimately), and unauthenticated-by-default makes it credential-free |
| rt-11-1 | Scrape-slot starvation | **REFUTED 2026-11-23 (verified)**: the cap exists (`MaxRequestsInFlight=10`, client_golang v1.25.0), but /metrics is ~17.8 KiB and the kernel send buffer autotunes to ~87 KiB, so neither rate-limited readers nor never-reading SO_RCVBUF sockets block the handler — the 11th scrape stays 200 and delivery is unaffected (Send-Q verified stuck at 14415 with the slot released). Scrape-surface DoS remains rate-storm territory (rt-4-5) | n/a — refuted; the harness pins both holder mechanisms so a body-size or buffer regression flips it | both mechanisms assert 200; plan's headline blindness row moves to rt-11-2 (FD knee) and rt-4-5 (storm) |
| rt-11-2 | FD exhaustion across the listener boundary | `max_connections`/accept-rate are not wired (documented). Thousands of idle connections to :9088/:8889 exhaust the process FD budget. Unlike rt-4-1, the target is not the API but the **collection path**: the per-namespace netlink sockets, `/proc` walk, and dockermeta reads all need FDs, and auth failures still consume the FD before the 401 | RLIMIT_NOFILE is per-process, idle timeouts 30–60 s | measure at which connection count polls start failing (`xtcp_counts` errors) vs. metrics still 200; finding = the unwired connection caps cross from API DoS into collection DoS |
| rt-11-3 | gRPC stream-slot grazing | 20 streams per connection, no global stream or connection quota; slow-reading `FlatRecords` streams and reflection/health spam add goroutines and buffer pressure to the shared process | 4 MB message cap, per-conn stream cap | bounded degradation only; assert no leak after churn (goroutine count via loopback pprof) |
| rt-11-4 | Own-netns dump amplification (poll-budget theft) | every cycle dumps *every* namespace on `-netlinkers 2` decoders with a 5 s per-namespace timeout. Attacker packs its own netns with tens of thousands of sockets (listener accept-queue backlog + timewait via self-SYN-flood + many listeners) so its dump alone eats seconds of the 10 s cadence; the host's and victims' dumps slide late or the cycle overruns | per-namespace `-timeout 5s`; poll timeout < frequency validation | measure poll-cycle latency and per-namespace coverage lag vs. attacker socket count; assert the timeout actually caps the thief |
Expand Down
18 changes: 18 additions & 0 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,24 @@ that supports the intended topology. Changing only IPv4 leaves IPv6 independent.
For precise exposure control, give each TCP listener a specific `address`, and
apply host/network firewall rules.

### Red-team-verified exposure grid (2026-11-23)

Measured in the Vagrant harness ([redteam-plan.md](redteam-plan.md) rt-9-1, rt-1-1),
Docker on Ubuntu 24.04 — which vantage can *reach* a TCP listener (the
credential gate is a separate question):

| Deployment row | VM host loopback | co-tenant container (docker0 gw) | remote host (private net) |
|---|---|---|---|
| `--network host`, `:9088` (the §29 prod shape) | 401 | 401 reachable | 401 reachable |
| `-p 9088:9088` (bridge, published) | 401 reachable | 401 reachable | 401 reachable |
| `--network host`, `127.0.0.1:9088`, `auth=disabled` | 200 | unreachable | unreachable |

Readings: every reachable cell is a 401 without a credential and a 200 with
the read token — reachability is gated by address choice, the credential gates
the content, and the low TTL bounds where replies can go. The loopback row is
the only shape an unauthenticated listener may take, and no other netns
reaches it.

## Optional loopback inspection listener

With the embedded monitor and `-linkMonitorIPPaths` enabled, a listener of its
Expand Down
2 changes: 1 addition & 1 deletion nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ let
redteam = import ./redteam.nix {
inherit pkgs lib src;
vagrant = redteamVagrant;
inherit (binaries) xtcp2client xtcp2ctl;
inherit (binaries) xtcp2client xtcp2ctl sockfill;
inherit (containers) oci-xtcp2 oci-xtcp2-tcp-stress;
};

Expand Down
Loading