From 2d493046210d0cb5579b3c34770a01f299f55da1 Mon Sep 17 00:00:00 2001 From: Garrett Allen <98648590+Gerrrt@users.noreply.github.com> Date: Sun, 22 Nov 2026 15:09:52 -0800 Subject: [PATCH] fix(range): test ragnarok's scope with a send that reports EPERM, not ping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit finish-attack-vm.sh's first run against ragnarok died on "a send to 1.1.1.1 was not refused", with the scope holding: Python's ICMP, raw ICMP and UDP sends to 1.1.1.1 all raised EPERM and eth0 sent nothing. Kali's iputils (20250605) reports a filtered send as packet loss and drops the error, so grepping ping's output for it could never pass. The check now sends a UDP datagram from Python and reads the PermissionError; the gateway ping stays only to resolve the MAC for the raw probe. Runbook §8 matches. Co-Authored-By: Claude Opus 5.5 --- docs/changelog.md | 15 +++++++++++++++ docs/runbooks/build-the-playground.md | 19 ++++++++++--------- scripts/finish-attack-vm.sh | 21 +++++++++++++++++---- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index b7c179b2..74845119 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,21 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-22 +- **`finish-attack-vm.sh` tests `ragnarok`'s scope with a send that reports + its refusal.** Its first run against `ragnarok` stopped with "a send to + `1.1.1.1` was not refused", but the scope itself held: + - Both tables were loaded as written, and the raw-frame check passed. + - Python's sends to `1.1.1.1` (ICMP, raw ICMP and UDP) each raised + `Operation not permitted`. + - `eth0` transmitted nothing during the tests. + + The check was the fault. It grepped `ping`'s output for that error, and + Kali's iputils (20250605) reports a refused send as plain packet loss + instead. The script and `build-the-playground.md` §8 now make the send + from Python, which raises the kernel's `EPERM`. This corrects the + 2026-11-13 entry on `ragnarok`'s outbound scope, which said the script + fails unless `ping` is refused. + - **`gandalf`'s AMT does not answer on the network.** The 2026-11-13 audit of `gandalf` found AMT's state unproven. The ME is present (`/dev/mei0`), and the OS cannot read whether it is provisioned. `build-the-playground.md` diff --git a/docs/runbooks/build-the-playground.md b/docs/runbooks/build-the-playground.md index 4c361d49..8854c70d 100644 --- a/docs/runbooks/build-the-playground.md +++ b/docs/runbooks/build-the-playground.md @@ -1034,19 +1034,20 @@ nft list ruleset 2>/dev/null | grep -Ei 'masquerade|snat' || echo "no NAT" iptables -t nat -S 2>/dev/null | grep -- '-j MASQUERADE' || echo "no legacy NAT" systemctl is-enabled nftables; sudo nft list chain inet range_scope output | grep 'policy drop' sudo nft list chain netdev range_scope_l2 egress | grep 'policy drop' -ping -n -c1 -W2 1.1.1.1 +python3 -c 'import socket; socket.socket(socket.AF_INET, socket.SOCK_DGRAM).sendto(b"x", ("1.1.1.1", 9))' ``` Both sysctls `= 0`, and no NAT from either table — Kali's `iptables` is nft-backed, so the two commands can disagree about a rule that exists. -`nftables` reads `enabled`, the `range_scope` chain is loaded with -`policy drop`, and the ping fails with *Operation not permitted*: the filter -refused it. A timeout is not a pass, because it is what the internet being down -looks like too. The raw-Ethernet half, a frame to `1.1.1.1` through a packet -socket that must raise `range_scope_l2`'s `out_of_scope` counter, needs a -crafted frame, so it is left to `finish-attack-vm.sh`. Run this after -installing anything that touches the network stack, and after any install that -lifted the scope, not just once. +`nftables` reads `enabled`, the `range_scope` chain is loaded with `policy +drop`, and the send fails with `PermissionError: [Errno 1] Operation not +permitted`: the filter refused it. Use the Python line, not `ping`. Kali's +`ping` (iputils 20250605) reports a refused send as plain packet loss, which +looks the same as the internet being down, so it proves nothing either way. The +raw-Ethernet half, a frame to `1.1.1.1` through a packet socket that must raise +`range_scope_l2`'s `out_of_scope` counter, needs a crafted frame, so it is left +to `finish-attack-vm.sh`. Run this after installing anything that touches the +network stack, and after any install that lifted the scope, not just once. **Four — a target has no route anywhere.** On a target: diff --git a/scripts/finish-attack-vm.sh b/scripts/finish-attack-vm.sh index c061163b..945a03a2 100755 --- a/scripts/finish-attack-vm.sh +++ b/scripts/finish-attack-vm.sh @@ -251,10 +251,23 @@ if [ -n "$legacy" ]; then echo "legacy NAT present"; else echo "no legacy NAT"; echo "nftables $(systemctl is-enabled nftables 2>/dev/null || echo disabled)" chain="$(nft list chain inet range_scope output 2>/dev/null)" || chain="" if printf '%s\n' "$chain" | grep -q 'policy drop;'; then echo "scope policy drop"; else echo "scope missing"; fi -p="$(ping -n -c1 -W2 1.1.1.1 2>&1)" || true -if printf '%s\n' "$p" | grep -q 'Operation not permitted'; then echo "egress refused"; else echo "egress not refused"; fi -p="$(ping -n -c1 -W2 10.0.30.1 2>&1)" || true -if printf '%s\n' "$p" | grep -q 'Operation not permitted'; then echo "segment refused"; else echo "segment allowed"; fi +# The send is made from Python, not ping: Kali's iputils (20250605) reports +# a send the filter refused as plain packet loss and drops the error, while +# Python raises the kernel's EPERM. UDP to the discard port, because the +# scope is by address and the protocol does not matter. The gateway ping +# after it stays for the raw probe below: it resolves the gateway's MAC. +send() { python3 -c 'import socket, sys +s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +try: + s.sendto(b"range-scope-probe", (sys.argv[1], 9)) + print("sent") +except PermissionError: + print("refused") +except OSError as e: + print("error", e.errno)' "$1"; } +if [ "$(send 1.1.1.1)" = refused ]; then echo "egress refused"; else echo "egress not refused"; fi +if [ "$(send 10.0.30.1)" = sent ]; then echo "segment allowed"; else echo "segment refused"; fi +ping -n -c1 -W2 10.0.30.1 >/dev/null 2>&1 || true # Raw Ethernet, which the ping cannot test: one ICMP echo to 1.1.1.1 written # to eth0 through a packet socket, addressed to the gateway's MAC the ping # above just resolved. The send may fail with ENOBUFS once the egress hook