Files
felhom.eu/documentation/audits/evidence-chaos-night-2026-09-17/round4.sh
T
adminandClaude Opus 5 eb638d303b
gates / gates (push) Successful in 22s
CHAOS NIGHT rounds 4-5: the box repairs its own tunnel, and survives docker dying
Round 4 (tunnel killed 10 min): cloudflared came back in ~97 seconds and the
CONTROLLER did it, not Docker - RestartCount=0 proves the unless-stopped policy
never acted, and the log shows the protected-infra recovery redeploying it.
health_critical fired at 21:43 and health_recovered closed it at 21:48, so the
alarm was not a dead end.

Round 4's drawn ACTION never ran, and that is recorded rather than re-run: the
round-2 power cut rebooted the guest, /tmp is cleared on boot, and the dashboard
password lived there. The off-site run was never triggered. Re-running a round
after watching it fail is how a drill starts choosing its own results. The file
now lives in /root, so round 10's hard reset cannot disarm rounds 6, 8 and 10.

Round 5 (docker restarted): all 26 containers back in 16 seconds, doors serving
again in ~40, controller_started true and correct, nothing missed. The household
loop is recorded as NOT SAMPLED - 0 lines because the round was shorter than its
2-minute sampling interval, which is not the same as 0 failures.

Two traps avoided and written down: round 5's own alarm snapshot was taken six
seconds after the controller started, from which controller_started looked
missing (it fired); and my check for the password file put its redirect on the
wrong host, reporting "not there" for a file that was present all along. Tenth
and eleventh of the same family tonight - a check whose own precondition was
wrong, answering confidently.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
2026-09-16 23:56:26 +02:00

44 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
# ROUND 4 — `offsite-run` (drawn app: mealie), while the tunnel is killed for 10 minutes.
# The off-site repository is ORPHANED (round 1 established that on this rebuilt box). The run is
# expected to REFUSE. That refusal is the measurement; the orphan is NOT repaired to get a nicer one.
set -u
E=/mnt/5_hdd/felhom.eu/git/felhom.eu/documentation/audits/evidence-chaos-night-2026-09-17
OUT=$E/round-4.txt
SCR=$(ls -d /tmp/claude-1000/-mnt-5-hdd-felhom-eu-git/*/scratchpad/chaos 2>/dev/null | head -1)
export SSHPASS=$(cat $SCR/boxroot.pw)
SSHO="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 -o NumberOfPasswordPrompts=1"
BOX(){ sshpass -e ssh $SSHO root@192.168.0.115 "$@" 2>/dev/null | grep -v "Warning: Permanently"; }
say(){ echo "$(date -u +%FT%TZ) $*" | tee -a $OUT; }
door(){ curl -sL -o /dev/null -w '%{http_code}' --max-time 12 -k -H "Host: $1.enkicsifelhom.hu" http://192.168.0.116/ 2>/dev/null; }
cat > $SCR/r4a.sh <<'PEOF'
#!/bin/bash
H="Host: felhom.enkicsifelhom.hu"; B=http://172.17.0.2:8080
curl -s -o /dev/null -D /tmp/.l -H "$H" -X POST --data-urlencode "password@/root/.pw" $B/login
S=$(grep -i '^set-cookie: felhom_session=' /tmp/.l | sed 's/.*felhom_session=\([^;]*\).*/\1/')
[ -z "$S" ] && { echo "ABORT: no session — mine, not the product's"; exit 1; }
C="Cookie: felhom_session=$S"
TOK=$(curl -s -H "$H" -H "$C" $B/backups/remote | grep -o 'name="csrf-token" content="[^"]*"' | sed 's/.*content="\([^"]*\)".*/\1/')
curl -s -o /dev/null -D /tmp/.r -H "$H" -H "$C" -X POST --data-urlencode "_csrf=$TOK" $B/backup/offbox/run
echo " POST /backup/offbox/run -> $(head -1 /tmp/.r)"
echo " flash: $(grep -i '^location:' /tmp/.r | sed 's/.*flash[_a-z]*=//' | python3 -c 'import sys,urllib.parse;print(urllib.parse.unquote_plus(sys.stdin.read().strip())[:220])' 2>/dev/null)"
echo " status: $(curl -s -H "$H" -H "$C" $B/backup/offbox/status | head -c 220)"
rm -f /tmp/.l /tmp/.r
PEOF
say "================ ROUND 4 : offsite-run (mealie), while: tunnel down 10min ================"
BEFORE=$(BOX 'pct exec 9201 -- docker ps -q | wc -l' | tr -d ' \r'); [ -z "$BEFORE" ] && BEFORE=0
say "--- BEFORE --- containers=$BEFORE recipes=$(door recipes) status=$(door status)"
say "--- ACTION: trigger the off-site run ---"
sshpass -e scp $SSHO -q $SCR/r4a.sh root@192.168.0.115:/tmp/r4a.sh
BOX 'pct push 9201 /tmp/r4a.sh /tmp/r4a.sh --perms 700; pct exec 9201 -- bash /tmp/r4a.sh; pct exec 9201 -- rm -f /tmp/r4a.sh; rm -f /tmp/r4a.sh' | tee -a $OUT
say "--- ACCIDENT: kill the tunnel for 10 minutes (it is NOT restarted by hand — whether it returns is the measurement) ---"
bash $E/inject.sh tunnel-down-10min 4 2>&1 | sed 's/^/ /' | tee -a $OUT
say "--- AFTER ---"
N=$(BOX 'pct exec 9201 -- docker ps -q | wc -l' | tr -d ' \r')
say " containers=$N (before $BEFORE) recipes=$(door recipes) status=$(door status)"
say " cloudflared: $(BOX 'pct exec 9201 -- docker ps -a --format "{{.Names}} {{.Status}}" | grep cloudflared')"
say "--- alarms ---"; bash $E/events.sh 8 | tee -a $OUT
say "================ END ROUND 4 ================"