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
5 changes: 3 additions & 2 deletions docs/redteam-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ cap matrix, and ship the runbook.

| # | Task | Scenario |
|---|---|---|
| 5.1 | Netlink write audit: `strace -f -e sendmsg,sendto` for a full cycle + `/ip` sweep + link monitor; classify every nlmsg_type; repeat on Ubuntu 22.04/5.15 | rt-5-1 |
| 5.1 | Netlink write audit: `strace -f -e sendmsg,sendto` for a full cycle + `/ip` sweep + link monitor; classify every nlmsg_type | rt-5-1 (the 22.04/5.15 parity repeat descoped 2026-12-01 — nobody should be older than the current LTS kernel) |
| 5.2 | setns scope audit: trace setns, assert netns-only | rt-5-2 |
| 5.3 | Privileged-container blast radius: exec in `--cap-add=ALL` xtcp2 container; attempt link flap, `ip netns exec`, mount; document each | rt-5-3 |
| 5.4 | Cap matrix: run daemon with each cap dropped × {discovery, inet_diag, ethtool, RDMA, monitor} | rt-5-4 |
Expand All @@ -299,7 +299,8 @@ cap matrix, and ship the runbook.

**Definition of done**

- [ ] rt-5-1 evidence: zero write-class netlink messages on 6.8 **and** 5.15; one-page appendix in findings.md with the strace classification method.
- [x] **Phase 5 part 1 complete (the audit rows)**: rt-5-1 **BLOCKED** (13/13, `20261201T033702-aa5f97b81-3052245` — **the ops question's first half answered: xtcp2 cannot write netlink on Ubuntu 24.04/6.8**, structurally (the 8 write-request builders are all behind `goip_write`/treatment tags, file-output only; `BuildRequest` refuses non-GET via `IsBuildableRequestType`; the only raw nlmsg_type literal is SOCK_DIAG_BY_FAMILY; rtnlmon's plan is 4× RTM_GET*) and at runtime (90 s strace over the locality fleet + a mid-window discovery: all 532 netlink sends decoded from their hex are read-class — 499 SOCK_DIAG_BY_FAMILY dumps, 7 route GETs (the 60 s locality refresh), 18 generic GETs (nlctrl/devlink/ethtool), 4 RDMA NLDEV GET dumps (client 5 op 1), 4 unresolved-fd discovery sends; zero write-shaped NLM_F flags); the fd→protocol map merges `/proc/net/netlink` across the root netns and every discovered netns — late-attach strace prints pre-attach fds as bare numbers and unknown-protocol types as hex, so the classifier trusts only the hex dump), rt-5-2 **BLOCKED** (7/7, `20261201T041823-aa5f97b81-3493329` — **the second half: setns is netns-only on both axes**: 2 calls in a 90 s window, both `CLONE_NEWNET` into nsfs `net:[...]` inodes — never user/pid/mount; nsfs inode readlink prefixes make the target check exact). The audit triage loop itself surfaced five harness lessons (runs 1–3 CONFIRMED were audit-parser bugs, not product — decode every send from the `-e write=all` hex, exempt the NLM_F_DUMP pair 0x300 from the write-flag mask, filter static builder greps on build tags; the fourth the first 40-scenario matrix caught — `sed \| head -6` under pipefail is a SIGPIPE coin flip, 54% measured, fixed head-first and re-verified 13/13 `20261201T102514-7d2b8039e-1253734`; the fifth the SECOND matrix caught — fd-number reuse: the window-end fd table maps a refresh's closed route-socket number to a later diag socket, misclassifying one GETLINK as a diag write, fixed with the residual-rule fallback + absolute flag rule, verified offline against all four evidence sets: 0 BAD, 1 reuse artifact on the failing set, synthetic writes still caught). All five encoded in the scenario/findings rows. The same matrices wobbled pre-existing rows (all unchanged code, all PASS solo on re-verification): matrix 1 — rt-2-2's known mint-boundary race (10/10 `20261201T101415-7d2b8039e-1107943`), rt-2-3 (6/6 `20261201T101847-7d2b8039e-1247531`), rt-4-2's held-FD window (11/11 `20261201T102254-7d2b8039e-1251931`); matrix 2 — rt-4-1's amplifier ratio measured 48x against the 50x floor (the observed band is 48–149x — baseline-sensitive ratio, absolute volume consistently 90K–257K lines/6s: the floor recalibrated to 25x, the rt-4-6 gate-recalibration shape — measured, not guessed); matrix 3 — a corrupted `Packages.gz` from archive.ubuntu.com cascaded 21 provisioning failures for an hour (apt discards the old index on a failed fetch, and a fresh VM/container has nothing old to fall back on — "Unable to locate package curl" until the mirror healed; fixed with a 3-try `apt_update` retry in common.sh + the attacker pre-warm, same family as the dpkg-lock fix from the 33-scenario matrix), and rt-11-6's single blindness sample got a 401 (a dying spray conn frees a conntrack entry for the next SYN — slot churn, not a refuted premise; the assert now polls the 000 within a 30 s bound). **Final regression: 40/40 PASS, 0 failed on `7961d2210` (matrix run `20261201T161137-7961d2210`; rt-5-1 522 sends / 0 reuse artifacts `20261201T180827-7961d2210-3049333`, rt-5-2 2 calls `20261201T181143-7961d2210-3058980`).**
- [x] rt-5-1 evidence: zero write-class netlink messages on Ubuntu 24.04 LTS (6.8) — the current-LTS kernel floor (the 22.04/5.15 parity repeat descoped 2026-12-01: nobody should run anything older than the current LTS, the fleet is 24.04/6.8, and the audit ran on exactly this kernel); one-page appendix in findings.md with the strace classification method. (DONE: 13/13, `20261201T033702-aa5f97b81-3052245` — all 532 sends read-class, zero write flags; the classification method + the five audit-triage harness lessons are recorded in the findings.md row)
- [ ] Cap matrix table PR'd into `docs/security.md` (cap × feature), each cell evidenced by a scenario run.
- [ ] rt-11-12 (netns entry poisoning) resolves BLOCKED (errors counted + gauge) or CONFIRMED (silent drop → S2 issue).
- [ ] RUNBOOK.md complete for all 7 links × 4 tiers (28 cells), each naming a concrete metric/log/absence-alert.
Expand Down
11 changes: 7 additions & 4 deletions docs/redteam-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ infrastructure itself (that is supply-chain hardening, tracked separately).
The baseline deployment the harness builds (mirroring TODO-SOON §29's prod
table):

- Ubuntu 24.04 guest (stock 6.8 kernel; also one 22.04/5.15 row for parity),
- Ubuntu 24.04 guest (stock 6.8 kernel — the current LTS floor; descoped
the earlier 22.04/5.15 parity row on 2026-12-01: nobody should be on
anything older than the current LTS, and the audits ran on exactly this
kernel),
Docker installed from Docker's apt repo.
- xtcp2 OCI image built from this repo (`nix build .#oci-xtcp2`, `docker load`),
run as prod does: `/var/lib/xtcp2` bind-mounted, read token via
Expand Down Expand Up @@ -195,8 +198,8 @@ and measure blast radius if the daemon process itself is compromised.

| ID | Scenario | Steps | Expected today | Pass criteria | Severity if failed |
|---|---|---|---|---|---|
| rt-5-1 | Netlink write audit (assurance) | `strace -f -e trace=sendmsg,sendto` on the daemon for a full poll + link-monitor cycle + `/ip` sweeps; also static grep for `RTM_NEW/SET/DEL` send sites in the daemon (not goip CLI) | only GET/dump requests and subscription registers | zero write-class nlmsg_type sent; failure = S1-class bug | S1 if violated |
| rt-5-2 | setns scope audit | trace `setns` syscalls; verify target fd ns types | only netns entered, never user/pid/mount | netns-only | S2 if violated |
| rt-5-1 | Netlink write audit (assurance) | `strace -f -e trace=sendmsg,sendto` on the daemon for a full poll + link-monitor cycle + `/ip` sweeps; also static grep for `RTM_NEW/SET/DEL` send sites in the daemon (not goip CLI) | **VERIFIED 2026-12-01 (BLOCKED — the write path does not exist, structurally and at runtime)**: static — the 8 write-request builders in the tree are ALL behind `goip_write`/treatment tags (the goip CLI's encoders, file output only; the daemon build sets none), `BuildRequest` refuses every non-GET nlmsg_type (`IsBuildableRequestType` + `ErrNotAGetRequest`), the daemon's only raw nlmsg_type literal is `uint16(20)` = SOCK_DIAG_BY_FAMILY, rtnlmon's dump plan is 4× RTM_GET*; dynamic (90 s strace over the locality fleet + a mid-window discovery, every send decoded from its `-e write=all` hex and classified against its fd's protocol via the merged `/proc/net/netlink` tables) — **all 532 sends read-class**: 499 SOCK_DIAG_BY_FAMILY dumps, 7 route GETs (the 60 s locality refresh), 18 generic GETs (nlctrl/devlink/ethtool), 4 RDMA NLDEV GET dumps, 4 unresolved-fd discovery sends; zero write-shaped NLM_F flags (13/13, `20261201T033702-aa5f97b81-3052245`; the shape ran a mid-window container discovery instead of `/ip` sweeps — a fresh netns exercises MORE of the surface: new socket, new listener, new setns). The 5.15 parity repeat is descoped (2026-12-01): Ubuntu 24.04 LTS ships 6.8, nobody should run older than the current LTS, and the fleet is 24.04/6.8 — the DoD is the 6.8 kernel, and the audit ran on it | zero write-class nlmsg_type sent; failure = S1-class bug | S1 if violated |
| rt-5-2 | setns scope audit | trace `setns` syscalls; verify target fd ns types | **VERIFIED 2026-12-01 (BLOCKED — netns-only on both axes)**: 90 s `strace -f -e trace=setns -y` window over the locality fleet + a mid-window discovery: 2 calls, both `setns(N<net:[...]>, CLONE_NEWNET) = 0` — the flag axis (never CLONE_NEWUSER/NEWPID/NEWNS) and the target axis (nsfs inode prefixes: `net:[...]` only, never user/pid/mnt) both clean; the 2 calls are the discovery enter + a locality-refresh enter of the new namespace (refresh threads terminate rather than restore; the ns-death restore fires only at namespace deletion) (7/7, `20261201T041823-aa5f97b81-3493329`) | netns-only | S2 if violated |
| rt-5-3 | Compromised-container blast radius (privileged) | exec a shell in the xtcp2 container run `--privileged` (or `--cap-add=ALL`) and attempt: link flap on host iface, `ip netns exec` into other netns, mount tricks | with host mounts (`/run/netns`, hostPID) the container can flip host links and enter other containers' netns | documents that privileged ≈ host compromise; pass criteria = minimum-cap deployment recipe (NET_ADMIN+SYS_ADMIN only, no SYS_PTRACE unless needed, no hostPID) and the finding that caps must be dropped | S1 guidance |
| rt-5-4 | Minimum-capability matrix | run daemon with each cap dropped; observe startup capability checks and function | capability checks explain missing privileges (existing feature) | produce the cap/feature matrix (discovery, inet_diag, ethtool, RDMA) so operators can drop SYS_ADMIN where mounts replace it | S3 |
| rt-5-5 | RDMA subscription on stock 6.8 | `rdma link add rxe0 type rxe netdev eth1` in the VM; daemon runs with embedded monitor | EOPNOTSUPP handled, baseline from polled state (TODO-SOON §29 row) | no fd leak / hot retry loop; `collection_healthy 1` | S3 |
Expand Down Expand Up @@ -433,7 +436,7 @@ Severity scale (impact on the Ubuntu host / fleet):
| 2 | Auth-on matrix | rt-2-*, rt-9-2, rt-9-3, rt-11-1..3 (read-cred tier) | every documented limitation re-tested on Ubuntu/Docker; auth-mode confusion issue filed |
| 3 | Admin abuse | rt-3-*, rt-7-1..3, rt-11 tier 4 rows | exfil and `dest: null` blind chains demonstrated end-to-end with detection gap notes |
| 4 | DoS suite | rt-4-1..8, rt-11-4..8 | connection-exhaustion measured (rt-4-1) and issue filed to wire limits |
| 5 | Host assurance | rt-5-*, rt-6-*, rt-9-4, rt-11-9..13 | netlink write audit clean on Ubuntu 6.8 + 5.15; cap matrix produced; blind-detection runbook written |
| 5 | Host assurance | rt-5-*, rt-6-*, rt-9-4, rt-11-9..13 | netlink write audit clean on Ubuntu 24.04 LTS (6.8) — the current LTS kernel floor; cap matrix produced; blind-detection runbook written |
| 6 | Parser/fuzz | rt-8-1..4 | hostile-netns harness reusable; fuzz campaigns green |
| 7 | Triage & close-out | all | findings.md complete; fixes or issues for every CONFIRMED; regression gates registered; security.md updated with Ubuntu/Docker specifics |

Expand Down
2 changes: 2 additions & 0 deletions nix/redteam.nix
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ in
redteam-rt-4-6
redteam-rt-4-8
redteam-rt-11-8
redteam-rt-5-1
redteam-rt-5-2
)
failed=0
for s in "''${scenarios[@]}"; do
Expand Down
23 changes: 21 additions & 2 deletions vagrant/provision/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,27 @@ for _ in $(seq 1 120); do # bounded: 10 min — an upgrade can run long
sleep 5
done

# apt-get update with transient-mirror retry: one corrupted Packages.gz
# fetch ("File has unexpected size", archive.ubuntu.com) once cascaded 21
# scenarios — apt discards the old index when a fetch fails, and on a fresh
# VM/container there is nothing old to fall back to, so the next install
# fails with "Unable to locate package" until the mirror heals. Three
# tries, 10 s apart, fails the provision only when the mirror is truly down.
apt_update() {
local i
for i in 1 2 3; do
if apt-get update -qq; then
return 0
fi
echo "provision: apt-get update failed (attempt $i/3) — retrying in 10s" >&2
sleep 10
done
echo "provision: apt-get update failed 3x — the mirror is down, not flaky" >&2
return 1
}

if ! command -v docker >/dev/null 2>&1; then
apt-get update -qq
apt_update
apt-get install -y -qq ca-certificates curl gnupg
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
Expand All @@ -46,7 +65,7 @@ if ! command -v docker >/dev/null 2>&1; then
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg]" \
"https://download.docker.com/linux/ubuntu noble stable" \
>/etc/apt/sources.list.d/docker.list
apt-get update -qq
apt_update
apt-get install -y -qq docker-ce docker-ce-cli containerd.io
fi

Expand Down
5 changes: 4 additions & 1 deletion vagrant/provision/victim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,10 @@ case "$ATTACKER_TIER" in
esac

# Pre-warm the attack tool so the scenario's docker exec is deterministic.
docker exec rt-attacker bash -c 'apt-get update -qq && apt-get install -y -qq curl'
# The update retries the same transient-mirror corruption the host side does
# (common.sh apt_update): the fresh container's empty lists turn one flaky
# fetch into "Unable to locate package curl" for the rest of the run.
docker exec rt-attacker bash -c 'for i in 1 2 3; do apt-get update -qq && break; sleep 10; done; apt-get install -y -qq curl'

docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}'
echo "victim: MODE=$MODE AUTH=$AUTH CAPS=$CAPS ATTACKER=$ATTACKER_TIER DEST=$DEST ENRICH=$ENRICH"
Loading