Skip to content
Open
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
4 changes: 2 additions & 2 deletions docs/redteam-implementation.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/redteam-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ userns, or `docker.sock` mounted — common in practice):
| rt-11-10 | Host netfilter blind | `iptables -I OUTPUT ... --dport 9092 -j DROP` (or INPUT to :9088/:8889) — silent delivery or scrape blind while the daemon is healthy | delivery-error metrics must light up; finding: firewall tampering is only detectable via delivery health, so those metrics must page |
| rt-11-11 | Netns flood via mount propagation | thousands of netns registered into a `rslave`-propagated `/run/netns` → discovery/reconcile every cycle stretches past cadence; each flooded netns can also carry rt-11-4's socket bomb | **MEASURED 2026-12-05: the flood KILLS the daemon — CONFIRMED (S2)** — the per-namespace collector inits (each locking an OS thread) pass the Go runtime's 2000-thread ceiling BEFORE the `-maxNetns` cap (4096) is reached (`fatal error: thread exhaustion`, exit 2, the catcher freezes — the full-fleet blind; the admission bounds and the thread ceiling are mutually inconsistent; fix = cap netns under the thread budget, unlock after init, or raise SetMaxThreads — a surviving build resolves the bounds path: coverage lag vs. netns count, the `checkNetnsPropagation` gauge stays correct, add_rate/max_netns engage) |
| rt-11-12 | Docker netns entry poisoning | with an rw bind of `/run/docker/netns` + shared propagation, replace victim netns files with dead inodes/symlinks → setns errors for *victim* namespaces → their sockets silently vanish from reports | error counters must increment and a namespace-level gauge must show the failure; silent drop = S2 finding |
| rt-11-13 | UDS unlink / baseline poisoning | rt-6-2/6-3/6-4 applied from a privileged neighbor | covered by RT-6 rows; repeat here in the Docker topology |
| rt-11-13 | UDS unlink / baseline poisoning | rt-6-2/6-3/6-4 applied from a privileged neighbor | **VERIFIED 2026-12-06: CONFIRMED (the #400/#401 legs land unchanged from the neighbor)** — the shared volume IS the attack: the neighbor unlinks the victim's LIVE socket (0600 in docker's 0755 bind dir — the rt-6-3 private-parent defense never runs on a pre-mounted dir) and binds its fake at the path (the twin keeps running and delivering — no `function="listener"` counter exists at all), while a capability-LESS co-tenant (‑‑cap-drop=ALL, not even xtcp2's two fatal caps — it parks as busybox) unlinks all the same: uid 0 owns the shared dir, owner-write needs no CAP_DAC_OVERRIDE; the baseline poison is written through the same mount and is LATENT (Store.LoadAndLock runs at startup only — 12 s with the poison in place: delta ≈0, ready=1) until ANY restart loads it: `go_link_monitor_up_links_delta = -99997` — the fake ~100k alert from one neighbor write, and the restart's stale-unlink re-take of the path is both the only theft recovery AND the poison's trigger (21/21, `20261206T180851-173217a25-1948319`) |

**Tier 4 — admin access** (auth disabled by default, or a stolen admin
token): the one-RPC full blind — `ConfigService.Set` with `dest: null:`
Expand Down
30 changes: 30 additions & 0 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,3 +722,33 @@ requirement is enforced, not just documented. The file on the mount is
still readable by whatever uid owns the host path: the 0400 requirement
and the read-only, daemon-owned parent dir are the deployment's to honor.
(10/10, `20261205T221425-4a9a9345b-1938524`.)

### The shared-volume topology (measured, red-team rt-11-13)

A **shared volume is the world-writable parent** — no chmod can repair it
(rt-11-13, 21/21, `20261206T180851-173217a25-1948319`). A neighbor
container with the victim's socket dir or baseline dir mounted `rw`
needs no exploit and **no capability** (a `--cap-drop=ALL` co-tenant
unlinks a live socket too — uid 0 owns the mount, owner-write needs no
CAP_DAC_OVERRIDE; the "privileged neighbor" overstates the requirement):

- **The unlink/hijack lands silently.** The neighbor unlinks the LIVE
socket (0600 in docker's 0755 bind dir — the `0750` socketDirMode only
creates, it never tightens a pre-mounted dir) and binds its own at the
path. The daemon keeps running, keeps delivering, and its exposition
has **no listener-family counter at all** — there is no daemon-side
signal for a stolen socket path; the operator's probe through the path
is the only detector (the RUNBOOK's external-watchdog rule).
- **The baseline poison is latent, then fires on any restart.** The
neighbor's single write to the shared baseline file does nothing to the
running daemon (`Store.LoadAndLock` runs at startup only) — the poison
waits for the next crash, upgrade, or node reboot, then loads as a
healthy baseline and pages a fake `up_links_delta ≈ −100k` alert
(#401's delivery leg). The one recovery for the stolen path — a
restart, whose stale-unlink re-takes it — is also the poison's
trigger.

The requirement is the deployment invariant: **never mount the daemon's
socket dir or `/var/lib/xtcp2` into another container** (the same rule
as the docker socket in "Blast radius of a compromised daemon
container").
21 changes: 18 additions & 3 deletions nix/redteam.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ let
goip
;
busybox = pkgs.pkgsStatic.busybox; # static musl build; argv[0] must be busybox
socat = pkgs.pkgsStatic.socat; # static musl build; rt-11-13 docker-cp's it into the neighbor container (the fake-socket bind)
};
attackerTools =
pkgs.runCommand "xtcp2-redteam-attacker-tools.tar"
Expand All @@ -101,10 +102,23 @@ let
# gRPC scenarios get a static build of their own when Phase 1 needs them
# (see docs/redteam-harness.md "Open questions").
for b in ${
lib.concatStringsSep " " (lib.mapAttrsToList (_: drv: "${drv}/bin/*") attackerToolsBinaries)
lib.concatStringsSep " " (
lib.mapAttrsToList (name: drv: "${drv}/bin/${name}") attackerToolsBinaries
)
}; do
# -L follows symlinks: busybox's /bin is one real ELF plus one
# symlink per applet, and the applets must pass the check too.
# The check covers exactly what the tar copies: every binary below
# must be a static ELF or it would not run on the Ubuntu guests.
# (socat's bin/ also ships a shell script — checked per-name, not by
# the glob, so only the real binary gates the build.)
file -L "$b" | grep -q 'statically linked' || {
echo "redteam-attacker-tools: $b is not a static ELF — it would not run on the Ubuntu guests" >&2
exit 1
}
done
# -L follows symlinks: busybox's /bin is one real ELF plus one symlink
# per applet, and every applet must pass the check too (argv[0] is the
# applet name when docker exec runs /bin/busybox rm etc.).
for b in ${pkgs.pkgsStatic.busybox}/bin/*; do
file -L "$b" | grep -q 'statically linked' || {
echo "redteam-attacker-tools: $b is not a static ELF — it would not run on the Ubuntu guests" >&2
exit 1
Expand Down Expand Up @@ -272,6 +286,7 @@ in
redteam-rt-11-10
redteam-rt-11-11
redteam-rt-11-12
redteam-rt-11-13
redteam-rt-6-1
redteam-rt-6-2
redteam-rt-6-3
Expand Down
1 change: 1 addition & 0 deletions vagrant/redteam/findings.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ that gets fixed flips its `EXPECT` in the same PR as the fix
| rt-6-4 | 2026-12-05 | host+raw+min; the row daemon (its own link monitor up — the healthy reference) untouched; two twins, each with its own baseline file in its own bind-mounted /var/lib/xtcp2 and its own socat catcher (:9995 corrupt, :9996 craft) | CONFIRMED | #401 (S3) | `20261205T212243-4a9a9345b-1502677` (17/17; runs a–c were scenario bugs: the authed 9088 scrape needs the read token (a 401 read as a permanent 0), a `catcher_gt 0` call left `$2` unbound under set -u (the silent death), and my twin-scoped `catcher_lines` shadowed invariant.sh's main-catcher one inside `victim_still_reporting` — renamed `twin_catcher_lines`) | **The two shapes split exactly: corrupt degrades safely, crafted-valid is the finding.** CORRUPT: the twin's monitor stops ONLY itself — `xtcp_gauges{function="linkMonitor",variable="up"}` 1→0, the failure counted, /healthz 200, and TCP collection UNAFFECTED (the twin's records keep flowing to its catcher) — the runLinkMonitor contract, repeated on Ubuntu/Docker. CRAFTED-VALID: `{"version":1,"expected_up_links":99999,"recorded_at":…}` is accepted without complaint (no hash, no mode check — `go_link_monitor_baseline_ready 1`; the poisoned record IS the durable baseline) and produces **`go_link_monitor_up_links_delta = -99997` — a fake ~100k "links missing" alert from ONE file write**, with the monitor up the whole time. Fix space (#401): an integrity check at load (the #341 family) or a bound: 99999 expected vs ~2 collectable up links should refuse. |
| rt-6-5 | 2026-12-05 | host+raw+min; the row daemon (its 0400 secrets — the reference) untouched; one twin with fresh 0644 tokens (the mistake shape) bind-mounted read-only | BLOCKED | — (the plan's premise is STALE — the refusal already exists) | `20261205T221425-4a9a9345b-1938524` (10/10; run 1 designed the row as CONFIRMED on the plan's "loader does not check file modes" premise — the measured refusal refuted it, and the row's "consider refusing world-readable secret files at startup" is already the product behavior) | **The listener REFUSES a group/world-readable secret file at startup — the row's premise is refuted.** The 0644 twin exits at startup: "listener 'prometheus': … a secret file must not be accessible by group or others (chmod 0400; Kubernetes secret defaultMode: 0400)" — the refusal names the rule and the fix. The read-side audit stands: the 0644 file is still world-readable ON THE MOUNT (`sudo -u nobody cat` reads the token — the refusal stops the daemon's USE, not the file's read; the 0400 requirement is the deployment's to honor), and the leaked token has nothing to answer (000 — no listener): the refusal precedes the exposure. The positive control: the 0400 twin starts and serves /metrics 200 with the token, and the row daemon's own secrets ship 0400 (victim.sh's provision). |
| rt-6-6 | 2026-12-05 | host+raw+min; the ROW daemon is the target (goip docker-cp'd into its own shell-less container — the rt-5-3 busybox pattern; argv[0] stays goip), plus a /ip twin (-linkMonitorIPPaths, `serves=…+ip`) | BLOCKED | — | `20261205T235143-4a9a9345b-2820953` (14/14; runs a–f were scenario bugs: goip prints "state UNKNOWN" for a loopback — the up/down signal is the flags list `<LOOPBACK,UP,LOWER_UP>`; a multiline awk program is a newline inside a single-quoted string; the expected-refusal exit 1 must be captured with the &&/|| idiom, never the bare $? after the command (set -e kills the scenario first); the /ip paths are an endpoint CLASS — the listener needs `serves=ip`) | **The confinement holds on every axis.** With `GOIP_WRITE_OUT` set, the write verbs (the goip_write-tagged build, run from the daemon's own container) write the request FILE only — the loopback flags `<LOOPBACK,UP,LOWER_UP>` unchanged after `link set lo down`, the route table unchanged after `route add 203.0.113.0/24`, the daemon undisturbed; without the variable the verbs refuse outright ("goip never applies a write", exit 1). The API: the row daemon serves /ip OFF by default (404); the /ip twin serves the read verb /ip/link (200) and refuses the write verb /i/l/s/dev/lo/down 400 BY NAME ("A write verb counts, so /i/l/s is refused as `ip link set`") — with no write encoder in the binary to reach (no-write-encoders, the flake check). |
| rt-11-13 | 2026-12-06 | host+raw+min; the row daemon untouched; the victim twin (health on the shared UDS path, metrics on loopback :9317, its own baseline in the shared /var/lib/xtcp2, its own catcher :9995) + the neighbor (a real xtcp2 co-tenant, the tier-3 cap shape, BOTH volumes rw, busybox+socat docker-cp'd in) + a capability-less co-tenant (docker create --cap-drop=ALL + cp busybox + start, parked as busybox sleep) for the no-cap leg | CONFIRMED | #400/#401 (the Docker-topology delivery legs — no new issue: the shared volume IS the attack) | `20261206T180851-173217a25-1948319` (21/21; run 1 was three scenario bugs: the scratch image has NO /bin/sh — socat's SYSTEM: runs its command through `sh -c`, so the fake-socket echo needs busybox docker-cp'd AS /bin/sh; it has no /tmp either — docker cp needs an existing parent, so the poison rides the shared mount; and `docker start` has no --entrypoint flag — the entrypoint is set at docker create) | **The RT-6 attacks land from a neighbor with no exploit at all — and the caps are irrelevant.** THEFT: the neighbor unlinks the victim twin's LIVE socket (0600, root-owned, in docker's 0755 bind dir — the rt-6-3 private-parent defense never runs on a pre-mounted dir) and binds its own fake at the path; the twin keeps running, /metrics stays 200, records keep flowing (catcher 22346→24168 through the theft), and NO `function="listener"` series exists in the exposition — there is no daemon-side counter for a stolen socket path, the operator's probe is the only detector. POISON: the neighbor overwrites the LIVE baseline file through the rw mount and it is LATENT — Store.LoadAndLock runs at startup only (12 s with the poison in place: delta ≈0, baseline_ready=1, the running daemon never re-reads it), then ANY restart (crash, upgrade, node reboot) loads it as a healthy baseline and fires `go_link_monitor_up_links_delta = -99997` — the fake ~100k alert from one neighbor write; and the restart's stale-unlink policy re-taking the path (removing the attacker's fake, /healthz 200) is both the ONLY theft recovery AND the poison's trigger. NOCAP: a capability-less co-tenant (--cap-drop=ALL — not even xtcp2's two fatal caps, it parks as busybox sleep) unlinks a live socket through the rw volume all the same — uid 0 owns the shared dir, owner-write needs no CAP_DAC_OVERRIDE: the volume mount, not any cap, is the attack, and the plan's "privileged neighbor" overstates the requirement. |
Loading