From 2e509c58650999adde13482719f8c05e7d6cbf47 Mon Sep 17 00:00:00 2001 From: Marketen Date: Tue, 3 Nov 2026 12:03:27 +0100 Subject: [PATCH 1/5] fix: deliver reversible CVE-2026-98432 mitigation on Ubuntu --- .github/workflows/mitigation-test.yml | 13 ++ docs/security/CVE-2026-98432.md | 86 +++++++++++++ src/entrypoint.sh | 11 +- src/scripts/mitigate_cve_2026_98432.sh | 170 +++++++++++++++++++++++++ src/upgrades/upgrade_014.sh | 6 + test/Dockerfile | 10 ++ test/test_mitigation.py | 163 ++++++++++++++++++++++++ 7 files changed, 457 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/mitigation-test.yml create mode 100644 docs/security/CVE-2026-98432.md create mode 100755 src/scripts/mitigate_cve_2026_98432.sh create mode 100755 src/upgrades/upgrade_014.sh create mode 100644 test/Dockerfile create mode 100644 test/test_mitigation.py diff --git a/.github/workflows/mitigation-test.yml b/.github/workflows/mitigation-test.yml new file mode 100644 index 0000000..4185bcd --- /dev/null +++ b/.github/workflows/mitigation-test.yml @@ -0,0 +1,13 @@ +name: Kernel mitigation tests +on: + push: + pull_request: + +jobs: + mitigation: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: docker build -t dappnode-cve-mitigation-test -f test/Dockerfile . + - run: docker run --rm --privileged dappnode-cve-mitigation-test + - run: docker run --rm dappnode-cve-mitigation-test shellcheck /tests/mitigate.sh /tests/upgrade_014.sh diff --git a/docs/security/CVE-2026-98432.md b/docs/security/CVE-2026-98432.md new file mode 100644 index 0000000..b1842d0 --- /dev/null +++ b/docs/security/CVE-2026-98432.md @@ -0,0 +1,86 @@ +# CVE-2026-98432 interim mitigation rollout + +Decision date: 3 November 2026. Wait for Canonical's released kernel fix; do not enable `-proposed` on users' machines. + +This release applies **temporary risk reduction**, not a kernel patch. Do not announce affected machines as fixed or fully protected. The migration does not install packages, change APT sources, restart Docker, or reboot. + +## What the Core update does + +`upgrade_014.sh` enters the host and runs `mitigate_cve_2026_98432.sh install` on Ubuntu. Other distributions are skipped; Debian users should use their distribution's released kernel security updates. `DISABLE_HOST_SCRIPTS=true` also skips this migration. + +The script records original host sysctl values and sets `net.mptcp.enabled=0` and `net.ipv4.tcp_migrate_req=0` where those keys exist. It adds two tagged IPv4 TCP rules to the raw table, at the start of PREROUTING and OUTPUT, dropping packets whose IPv4 header contains options (`IHL > 5`). It never flushes or saves the rest of the firewall. Normal TCP header options and IPv6 are not matched. + +PREROUTING covers the usual host ingress and Docker bridge/published-port DNAT path. OUTPUT covers host-originated traffic, including loopback. The sysctls apply to the host network namespace; they do not change existing container namespaces. Container-local traffic and datapaths bypassing host netfilter, such as macvlan/ipvlan or some BPF/XDP configurations, are outside this mitigation's coverage. BPF-driven request migration is also not ruled out by the sysctl. Kernel updates remain necessary. + +Disabling MPTCP can affect applications explicitly requiring MPTCP. Blocking IP options can affect NetLabel/CIPSO and other specialised networks. Canary these workloads before rollout. + +Persistent files: + +- `/usr/local/lib/dappnode/mitigate_cve_2026_98432.sh`: standalone install/apply/status/remove utility. +- `/var/lib/dappnode/cve-2026-98432/`: original settings, lock and explicit-removal sentinel. +- `/etc/sysctl.d/99-dappnode-cve-2026-98432.conf`: settings for keys present at install time. +- `/etc/systemd/system/dappnode-cve-2026-98432.{service,timer}`: boot application and one-minute repair/check interval. +- `/usr/src/dappnode/DNCORE/security/cve-2026-98432.status`: last operation result for DappManager. + +The timer repairs accidental removal of these two rules; a firewall reload may still create an exposure window before the next run. DappManager checks live state rather than trusting a previous successful status file. No claim is made about exploit resistance. + +## Developer release steps + +1. Review the companion DappManager PR and this Core PR. Keep both draft until canary results are recorded. Existing original worktrees were not modified by this work. +2. Run the disposable Linux tests: + + ```sh + docker build -t dappnode-cve-mitigation-test -f test/Dockerfile . + docker run --rm --privileged dappnode-cve-mitigation-test + docker run --rm dappnode-cve-mitigation-test shellcheck /tests/mitigate.sh /tests/upgrade_014.sh + ``` + + These exercise real netfilter with harmless connections and IPv4 options, including a DNATed network namespace; they do not attempt exploitation. systemctl is a test stub, while generated units are checked by `systemd-analyze verify`. They do not replace a real systemd boot/hardware canary. +3. On representative Ubuntu Dappnodes, with console recovery available, run the new Core build. Cover both architecture families used in the fleet, iptables-nft and iptables-legacy where deployed, WireGuard/OpenVPN, DNS, execution/consensus clients and validator connectivity. Include machines with and without the MPTCP sysctl. Verify real reboot persistence, timer repair after a managed firewall reload, and no duplicate rules after a Core restart. +4. Publish a DappManager patch release using its [Main workflow](https://github.com/dappnode/DNP_DAPPMANAGER/actions/workflows/main.yml) from the reviewed release branch. Use `bump=patch` and record the actual resulting version; do not guess a version from the development manifest. +5. Publish a Core patch release using its [Main workflow](https://github.com/dappnode/DNP_CORE/actions/workflows/main.yml). Set `core=patch`, use the newly published DappManager dependency version, and preserve all other intended dependency versions. This workflow publishes the package; merging alone does not distribute it. Review the generated `update-versions` PR as usual. +6. Announce: **“Update Dappnode Core to version to apply a temporary mitigation on Ubuntu. This reduces exposure; an official kernel update is still required. No reboot is needed to activate this temporary mitigation.”** Users who disabled automatic Core updates must update manually. Existing automatic Core updates include a 24-hour delay. Fresh script/ISO installs do not necessarily include the Core migration container; do not claim installer coverage without explicitly ensuring the new Core update runs. +7. Verify the installed state on canaries and watch DappManager for failed/unverified mitigation alerts. Users with host scripts disabled need a separate operator-managed response. DappManager's generic host-update button does not install this mitigation and does not select proposed kernel packages. + +## Host verification and recovery + +Run these on the Linux Dappnode host, not inside DappManager: + +```sh +sudo bash /usr/local/lib/dappnode/mitigate_cve_2026_98432.sh status +sudo systemctl status dappnode-cve-2026-98432.timer +sudo journalctl -u dappnode-cve-2026-98432.service +sudo iptables -t raw -S PREROUTING +sudo iptables -t raw -S OUTPUT +sudo sysctl net.mptcp.enabled net.ipv4.tcp_migrate_req +``` + +`mitigated` means the two live firewall rules and supported host sysctls are present. It does not indicate kernel patch status. A missing sysctl is expected on some kernels. A failed install retains its snapshots so rerunning the installed utility's `install` command, or rerunning the new Core container if the utility was not copied yet, can recover without losing original settings. The script's stderr and Core logs explain failures such as missing iptables/`xt_u32` support. + +To undo the mitigation (also usable immediately for operational problems): + +```sh +sudo bash /usr/local/lib/dappnode/mitigate_cve_2026_98432.sh remove +``` + +This disables its units, deletes only its tagged firewall rules and dedicated config files, and restores recorded sysctl values unless a later administrator change moved the live value away from zero. It leaves a removal sentinel so subsequent Core runs respect the rollback. If rollback fails, retain the saved state and retry `remove`; `status` stays failed until removal completes. To intentionally re-enable after a successful removal: + +```sh +sudo rm /var/lib/dappnode/cve-2026-98432/removed +sudo bash /usr/local/lib/dappnode/mitigate_cve_2026_98432.sh install +``` + +## When Canonical publishes the official update + +1. Check Canonical's tracker and the actual APT candidate for the host release and kernel flavour. Apply the released kernel through **System → Host → Update and upgrade** in the new DappManager (or normal operator-managed package updates). +2. Reboot at the operator's chosen time. Confirm `uname -r` and the running image package version against the appropriate vendor fixed version. Check networking and validator recovery. A successful APT command or absence of `/run/reboot-required` is not sufficient evidence of this CVE being fixed. +3. Once the running kernel is verified fixed, run the removal command above. The current release deliberately does not guess when it is safe to remove the workaround automatically. Plan a later verified cleanup migration for the fleet. + +## Sources + +- [Canonical advisory and release status](https://ubuntu.com/blog/fixes-available-in-proposed-pocket-for-cve-2026-98432) +- [Ubuntu CVE tracker and filtering limitations](https://ubuntu.com/security/CVE-2026-98432) +- [Akamai research and temporary sysctls](https://www.akamai.com/blog/security-research/cve-2026-98432-remote-uaf-linux-kernels-tcp-stack) +- [AWS security bulletin with iptables example](https://aws.amazon.com/security/security-bulletins/2026-160-aws/) +- [Red Hat advisory and incomplete filtering protection](https://access.redhat.com/security/vulnerabilities/RHSB-2026-016) +- [Linux MPTCP sysctl namespace semantics](https://docs.kernel.org/networking/mptcp-sysctl.html) diff --git a/src/entrypoint.sh b/src/entrypoint.sh index a82de33..d93d9a8 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -2,6 +2,7 @@ STATUS_CHECK_DELAY=1m CONTAINER_NAME=DAppNodeCore-dappmanager.dnp.dappnode.eth DAPPMANAGER_YML=/usr/src/dappnode/DNCORE/docker-compose-dappmanager.yml +upgrades_failed=0 if [[ "$DISABLE_HOST_SCRIPTS" == "true" ]]; then echo "DISABLE_HOST_SCRIPTS is set to true, skipping host scripts copy and upgrades execution" @@ -18,7 +19,10 @@ else # Apply all local upgrades for filename in ./upgrades/upgrade_*.sh; do echo "Applying upgrade ${filename}..." - sh "${filename}" + if ! sh "${filename}"; then + echo "ERROR: upgrade ${filename} failed" >&2 + upgrades_failed=1 + fi done fi @@ -40,4 +44,7 @@ elif [[ $RUNNING_IMAGE != $YML_IMAGE ]];then echo "YML_VERSION=${YML_VERSION} - RUNNING_VERSION=${RUNNING_VERSION}" docker-compose -f $DAPPMANAGER_YML up -d <&- fi -fi \ No newline at end of file +fi + +# Restore DappManager above even if a host migration failed, then expose failure. +exit "$upgrades_failed" diff --git a/src/scripts/mitigate_cve_2026_98432.sh b/src/scripts/mitigate_cve_2026_98432.sh new file mode 100755 index 0000000..17bd38d --- /dev/null +++ b/src/scripts/mitigate_cve_2026_98432.sh @@ -0,0 +1,170 @@ +#!/bin/bash +# Interim risk reduction, NOT a kernel fix. No APT sources or packages are changed. +# https://ubuntu.com/security/CVE-2026-98432 +# https://www.akamai.com/blog/security-research/cve-2026-98432-remote-uaf-linux-kernels-tcp-stack +set -Eeuo pipefail + +state_dir=/var/lib/dappnode/cve-2026-98432 +script_path=/usr/local/lib/dappnode/mitigate_cve_2026_98432.sh +sysctl_file=/etc/sysctl.d/99-dappnode-cve-2026-98432.conf +unit=dappnode-cve-2026-98432 +unit_dir=/etc/systemd/system +status_file=/usr/src/dappnode/DNCORE/security/cve-2026-98432.status +keys=(net.mptcp.enabled net.ipv4.tcp_migrate_req) +rule=(-p tcp -m u32 --u32 '0>>24&0x0f=6:15' -m comment --comment dappnode-cve-2026-98432 -j DROP) + +write_status() { + mkdir -p "$(dirname "$status_file")" + printf '%s\n' "$1" > "$status_file.tmp" + mv "$status_file.tmp" "$status_file" +} + +check_rules() { + local chain key value + for chain in PREROUTING OUTPUT; do + iptables -w 5 -t raw -C "$chain" "${rule[@]}" 2>/dev/null || return 1 + done + for key in "${keys[@]}"; do + if value=$(sysctl -n "$key" 2>/dev/null); then + [[ "$value" == 0 ]] || return 1 + elif [[ -f "$state_dir/$key.original" ]]; then + # A previously present key becoming unreadable is not success. + return 1 + fi + done +} + +status() { + if [[ -f "$state_dir/removed" ]]; then + if [[ -f "$status_file" && $(cat "$status_file") == removed ]]; then echo removed; else echo failed; fi + elif [[ -f "$status_file" && $(cat "$status_file") == failed ]]; then + echo failed + elif [[ -d "$state_dir" ]] && check_rules; then + echo mitigated + elif [[ -f "$status_file" ]] && [[ $(cat "$status_file") == not-applicable ]]; then + echo not-applicable + else + echo failed + fi +} + +apply() { + [[ ! -f "$state_dir/removed" ]] || return 0 + local key value chain + # Record original values once. Repeated boot/timer runs never replace them. + for key in "${keys[@]}"; do + if value=$(sysctl -n "$key" 2>/dev/null); then + [[ "$value" == 0 || "$value" == 1 ]] + if [[ ! -f "$state_dir/$key.original" ]]; then + printf '%s\n' "$value" > "$state_dir/$key.original" + fi + fi + done + # PREROUTING covers host INPUT and normal Docker bridge/DNAT forwarding. + # OUTPUT also covers host-originated traffic and loopback. Never flush rules. + for chain in PREROUTING OUTPUT; do + if ! iptables -w 5 -t raw -C "$chain" "${rule[@]}" 2>/dev/null; then + iptables -w 5 -t raw -I "$chain" 1 "${rule[@]}" + fi + done + for key in "${keys[@]}"; do + if [[ -f "$state_dir/$key.original" ]]; then sysctl -w "$key=0"; fi + done + check_rules + write_status mitigated +} + +install() { + # Respect an explicit administrator rollback, including future core restarts. + [[ ! -f "$state_dir/removed" ]] || { echo 'Mitigation was explicitly removed; skipping'; return 0; } + # shellcheck disable=SC1091 + . /etc/os-release + if [[ ${ID:-} != ubuntu ]]; then write_status not-applicable; return 0; fi + command -v iptables >/dev/null + command -v sysctl >/dev/null + # Make rollback available before applying any network changes. + mkdir -p "$(dirname "$script_path")" + if [[ $(readlink -f "$0") != "$script_path" ]]; then command install -m 755 "$0" "$script_path"; fi + apply + { + echo '# Managed by Dappnode: CVE-2026-98432 temporary mitigation' + for key in "${keys[@]}"; do + if [[ -f "$state_dir/$key.original" ]]; then printf '%s = 0\n' "$key"; fi + done + } > "$sysctl_file" + cat > "$unit_dir/$unit.service" < "$unit_dir/$unit.timer" </dev/null + while iptables -w 5 -t raw -C "$chain" "${rule[@]}" 2>/dev/null; do + iptables -w 5 -t raw -D "$chain" "${rule[@]}" + done + done + for key in "${keys[@]}"; do + if [[ -f "$state_dir/$key.original" ]]; then + value=$(cat "$state_dir/$key.original") + [[ "$value" == 0 || "$value" == 1 ]] + # Preserve later administrator changes away from the forced value. + if [[ $(sysctl -n "$key") == 0 ]]; then sysctl -w "$key=$value"; fi + fi + done + rm -f "$sysctl_file" "$unit_dir/$unit.service" "$unit_dir/$unit.timer" + systemctl daemon-reload + write_status removed + echo 'Temporary mitigation removed. This does not verify kernel patch status.' +} + +command=${1:-install} +case "$command" in + install|apply|remove|status) ;; + *) echo "Usage: $0 {install|apply|status|remove}" >&2; exit 2 ;; +esac +[[ $EUID == 0 ]] || { echo 'Must run on the host as root' >&2; exit 1; } +if [[ "$command" == status ]]; then status; exit 0; fi +mkdir -p "$state_dir" +chmod 700 "$state_dir" +exec 9>"$state_dir/lock" +flock -w 30 9 +trap 'write_status failed' ERR +"$command" diff --git a/src/upgrades/upgrade_014.sh b/src/upgrades/upgrade_014.sh new file mode 100755 index 0000000..921f68f --- /dev/null +++ b/src/upgrades/upgrade_014.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Apply the reversible interim mitigation on Ubuntu; never install proposed kernels. +set -eu +docker run --rm --privileged --pid=host alpine:3.18.2 \ + nsenter -t 1 -m -u -n -i /bin/bash \ + /usr/src/dappnode/DNCORE/scripts/upgrade/mitigate_cve_2026_98432.sh install diff --git a/test/Dockerfile b/test/Dockerfile new file mode 100644 index 0000000..d5b7502 --- /dev/null +++ b/test/Dockerfile @@ -0,0 +1,10 @@ +FROM ubuntu:24.04 +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + iptables iproute2 procps python3 systemd shellcheck && rm -rf /var/lib/apt/lists/* +WORKDIR /tests +COPY src/scripts/mitigate_cve_2026_98432.sh /tests/mitigate.sh +COPY src/upgrades/upgrade_014.sh /tests/upgrade_014.sh +COPY src/entrypoint.sh /tests/entrypoint.sh +COPY test/test_mitigation.py /tests/test_mitigation.py +ENV DAPPNODE_CVE_TEST_CONTAINER=1 +CMD ["python3", "-m", "unittest", "-v", "test_mitigation.py"] diff --git a/test/test_mitigation.py b/test/test_mitigation.py new file mode 100644 index 0000000..25a5d16 --- /dev/null +++ b/test/test_mitigation.py @@ -0,0 +1,163 @@ +"""Harmless packet and lifecycle tests; run only in the disposable privileged container.""" +import os +from pathlib import Path +import shutil +import socket +import subprocess +import time +import tempfile +import unittest + +SCRIPT = "/tests/mitigate.sh" +STATE = Path("/var/lib/dappnode/cve-2026-98432") +RULE = ["-p", "tcp", "-m", "u32", "--u32", "0>>24&0x0f=6:15", "-m", "comment", "--comment", "dappnode-cve-2026-98432", "-j", "DROP"] + + +def run(*args, check=True, env=None): + return subprocess.run(args, text=True, capture_output=True, check=check, env=env) + + +@unittest.skipUnless(os.environ.get("DAPPNODE_CVE_TEST_CONTAINER") == "1" and Path("/.dockerenv").exists(), "disposable privileged Docker container required") +class MitigationTests(unittest.TestCase): + def setUp(self): + for chain in ("PREROUTING", "OUTPUT"): + while run("iptables", "-t", "raw", "-C", chain, *RULE, check=False).returncode == 0: + run("iptables", "-t", "raw", "-D", chain, *RULE) + shutil.rmtree(STATE, ignore_errors=True) + Path("/usr/src/dappnode/DNCORE/security").mkdir(parents=True, exist_ok=True) + Path("/usr/src/dappnode/DNCORE/security/cve-2026-98432.status").unlink(missing_ok=True) + # Exercise systemd wiring without needing PID 1 to be systemd in Docker. + Path("/usr/local/bin/systemctl").write_text('#!/bin/sh\nprintf "%s\\n" "$*" >> /tmp/systemctl-calls\nexit 0\n') + Path("/usr/local/bin/systemctl").chmod(0o755) + Path("/usr/local/bin/sysctl").unlink(missing_ok=True) + run("/usr/sbin/sysctl", "-w", "net.ipv4.tcp_migrate_req=1") + + def install(self): + result = run("bash", SCRIPT, "install") + self.assertIn("Temporary mitigation installed", result.stdout) + self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "mitigated") + + def test_lifecycle_reapply_detection_and_rollback(self): + self.install() + original = STATE / "net.ipv4.tcp_migrate_req.original" + self.assertEqual(original.read_text().strip(), "1") + self.assertEqual(run("sysctl", "-n", "net.ipv4.tcp_migrate_req").stdout.strip(), "0") + # Missing MPTCP is supported; never fabricate a sysctl on such kernels. + if run("sysctl", "-n", "net.mptcp.enabled", check=False).returncode: + self.assertNotIn("net.mptcp.enabled", Path("/etc/sysctl.d/99-dappnode-cve-2026-98432.conf").read_text()) + run("bash", SCRIPT, "install") + self.assertEqual(original.read_text().strip(), "1") + self.assertEqual(run("iptables", "-t", "raw", "-S").stdout.count("dappnode-cve-2026-98432"), 2) + run("systemd-analyze", "verify", "/etc/systemd/system/dappnode-cve-2026-98432.service", "/etc/systemd/system/dappnode-cve-2026-98432.timer") + run("iptables", "-t", "raw", "-D", "PREROUTING", *RULE) + self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "failed") + run("bash", SCRIPT, "apply") + self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "mitigated") + run("bash", SCRIPT, "remove") + self.assertEqual(run("sysctl", "-n", "net.ipv4.tcp_migrate_req").stdout.strip(), "1") + self.assertNotIn("dappnode-cve-2026-98432", run("iptables", "-t", "raw", "-S").stdout) + self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "removed") + run("bash", SCRIPT, "remove") # Idempotent removal. + run("bash", SCRIPT, "install") # Core replay respects an explicit rollback. + self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "removed") + + def test_failed_apply_is_not_reported_as_mitigated(self): + Path("/usr/local/bin/sysctl").write_text('#!/bin/sh\ncase "$*" in "-w net.ipv4.tcp_migrate_req=0") exit 1;; esac\nexec /usr/sbin/sysctl "$@"\n') + Path("/usr/local/bin/sysctl").chmod(0o755) + result = run("bash", SCRIPT, "install", check=False) + self.assertNotEqual(result.returncode, 0) + self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "failed") + self.assertTrue((STATE / "net.ipv4.tcp_migrate_req.original").exists()) + Path("/usr/local/bin/sysctl").unlink() + run("bash", SCRIPT, "install") # Retry after a partial failure. + self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "mitigated") + + def test_host_forwarded_and_loopback_packets(self): + self.install() + servers = [] + try: + run("ip", "netns", "add", "peer") + run("ip", "netns", "add", "backend") + for namespace, subnet in (("peer", "10.90.0"), ("backend", "10.91.0")): + host = "cv-" + namespace + run("ip", "link", "add", host, "type", "veth", "peer", "name", "eth0", "netns", namespace) + run("ip", "addr", "add", subnet + ".1/24", "dev", host) + run("ip", "link", "set", host, "up") + run("ip", "-n", namespace, "addr", "add", subnet + ".2/24", "dev", "eth0") + run("ip", "-n", namespace, "link", "set", "eth0", "up") + run("ip", "-n", namespace, "link", "set", "lo", "up") + run("ip", "-n", namespace, "route", "add", "default", "via", subnet + ".1") + run("sysctl", "-w", "net.ipv4.ip_forward=1") + # Model Docker's published port: incoming TCP is DNATed to another namespace. + nat = ["-i", "cv-peer", "-p", "tcp", "--dport", "18081", "-j", "DNAT", "--to-destination", "10.91.0.2:18081"] + run("iptables", "-t", "nat", "-A", "PREROUTING", *nat) + servers.append(subprocess.Popen(["python3", "-m", "http.server", "18080", "--bind", "0.0.0.0"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)) + servers.append(subprocess.Popen(["ip", "netns", "exec", "backend", "python3", "-m", "http.server", "18081", "--bind", "0.0.0.0"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)) + time.sleep(0.5) + for prefix, address, port in ((["ip", "netns", "exec", "peer"], "10.90.0.1", 18080), (["ip", "netns", "exec", "peer"], "10.90.0.1", 18081), ([], "127.0.0.1", 18080)): + for options in (False, True): + code = f'''import socket +s=socket.socket(); s.settimeout(1) +s.setsockopt(socket.IPPROTO_TCP, socket.TCP_MAXSEG, 1200) +if {options}: s.setsockopt(socket.IPPROTO_IP, socket.IP_OPTIONS, bytes([1,1,1,0])) +try: + s.connect(({address!r}, {port})); s.sendall(b"GET / HTTP/1.0\\r\\n\\r\\n"); data=s.recv(100); assert data +except (TimeoutError, OSError): + raise SystemExit(1) +''' + result = run(*prefix, "python3", "-c", code, check=False) + self.assertEqual(result.returncode, 1 if options else 0, result.stderr) + counters = run("iptables", "-t", "raw", "-L", "-n", "-v", "-x").stdout + drops = [int(line.split()[0]) for line in counters.splitlines() if "dappnode-cve-2026-98432" in line] + self.assertEqual(len(drops), 2) + self.assertTrue(all(count > 0 for count in drops), counters) + finally: + for server in servers: + server.terminate() + server.wait() + for namespace in ("peer", "backend"): + run("ip", "netns", "del", namespace, check=False) + run("iptables", "-t", "nat", "-D", "PREROUTING", *nat, check=False) if "nat" in locals() else None + + def test_persistence_failure_stays_visible_even_when_rules_are_live(self): + Path("/usr/local/bin/systemctl").write_text('#!/bin/sh\nexit 1\n') + result = run("bash", SCRIPT, "install", check=False) + self.assertNotEqual(result.returncode, 0) + self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "failed") + + def test_entrypoint_starts_manager_before_reporting_upgrade_failure(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + for child in ("upgrades", "scripts", "deb", "bin"): + (root / child).mkdir() + (root / "upgrades/upgrade_014.sh").write_text("exit 17\n") + (root / "scripts/noop.sh").write_text("exit 0\n") + (root / "packages-content-hash.csv").write_text("") + for name, body in { + "sleep": "exit 0", + "docker": "echo false", + "docker-compose": "echo manager-started" + }.items(): + stub = root / "bin" / name + stub.write_text("#!/bin/sh\n" + body + "\n") + stub.chmod(0o755) + Path("/usr/src/dappnode/DNCORE/docker-compose-dappmanager.yml").write_text("image: example:1\n") + env = dict(os.environ, PATH=str(root / "bin") + ":" + os.environ["PATH"]) + result = subprocess.run(["bash", "/tests/entrypoint.sh"], cwd=root, env=env, capture_output=True, text=True) + self.assertEqual(result.returncode, 1) + self.assertIn("manager-started", result.stdout) + self.assertIn("upgrade_014.sh failed", result.stderr) + env["DISABLE_HOST_SCRIPTS"] = "true" + result = subprocess.run(["bash", "/tests/entrypoint.sh"], cwd=root, env=env, capture_output=True, text=True) + self.assertEqual(result.returncode, 0) + + def test_non_ubuntu_is_skipped(self): + path = Path("/etc/os-release") + original = path.read_text() + try: + path.write_text('ID=debian\nVERSION_CODENAME=bookworm\n') + run("bash", SCRIPT, "install") + self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "not-applicable") + self.assertNotIn("dappnode-cve-2026-98432", run("iptables", "-t", "raw", "-S").stdout) + finally: + path.write_text(original) From cc572fdda67171b9cadf0d275096513153617fc7 Mon Sep 17 00:00:00 2001 From: Marc Font <36164126+Marketen@users.noreply.github.com> Date: Tue, 3 Nov 2026 12:06:56 +0100 Subject: [PATCH 2/5] Potential fix for pull request finding 'CodeQL / Workflow does not contain permissions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .github/workflows/mitigation-test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/mitigation-test.yml b/.github/workflows/mitigation-test.yml index 4185bcd..81f7471 100644 --- a/.github/workflows/mitigation-test.yml +++ b/.github/workflows/mitigation-test.yml @@ -3,6 +3,9 @@ on: push: pull_request: +permissions: + contents: read + jobs: mitigation: runs-on: ubuntu-latest From 19d7f958b244118e1f062d8f648c5f2946dd72bf Mon Sep 17 00:00:00 2001 From: Marketen Date: Tue, 3 Nov 2026 12:10:14 +0100 Subject: [PATCH 3/5] chore: keep mitigation PR focused on runtime scripts --- .github/workflows/mitigation-test.yml | 16 --- docs/security/CVE-2026-98432.md | 86 -------------- src/entrypoint.sh | 11 +- test/Dockerfile | 10 -- test/test_mitigation.py | 163 -------------------------- 5 files changed, 2 insertions(+), 284 deletions(-) delete mode 100644 .github/workflows/mitigation-test.yml delete mode 100644 docs/security/CVE-2026-98432.md delete mode 100644 test/Dockerfile delete mode 100644 test/test_mitigation.py diff --git a/.github/workflows/mitigation-test.yml b/.github/workflows/mitigation-test.yml deleted file mode 100644 index 81f7471..0000000 --- a/.github/workflows/mitigation-test.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Kernel mitigation tests -on: - push: - pull_request: - -permissions: - contents: read - -jobs: - mitigation: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: docker build -t dappnode-cve-mitigation-test -f test/Dockerfile . - - run: docker run --rm --privileged dappnode-cve-mitigation-test - - run: docker run --rm dappnode-cve-mitigation-test shellcheck /tests/mitigate.sh /tests/upgrade_014.sh diff --git a/docs/security/CVE-2026-98432.md b/docs/security/CVE-2026-98432.md deleted file mode 100644 index b1842d0..0000000 --- a/docs/security/CVE-2026-98432.md +++ /dev/null @@ -1,86 +0,0 @@ -# CVE-2026-98432 interim mitigation rollout - -Decision date: 3 November 2026. Wait for Canonical's released kernel fix; do not enable `-proposed` on users' machines. - -This release applies **temporary risk reduction**, not a kernel patch. Do not announce affected machines as fixed or fully protected. The migration does not install packages, change APT sources, restart Docker, or reboot. - -## What the Core update does - -`upgrade_014.sh` enters the host and runs `mitigate_cve_2026_98432.sh install` on Ubuntu. Other distributions are skipped; Debian users should use their distribution's released kernel security updates. `DISABLE_HOST_SCRIPTS=true` also skips this migration. - -The script records original host sysctl values and sets `net.mptcp.enabled=0` and `net.ipv4.tcp_migrate_req=0` where those keys exist. It adds two tagged IPv4 TCP rules to the raw table, at the start of PREROUTING and OUTPUT, dropping packets whose IPv4 header contains options (`IHL > 5`). It never flushes or saves the rest of the firewall. Normal TCP header options and IPv6 are not matched. - -PREROUTING covers the usual host ingress and Docker bridge/published-port DNAT path. OUTPUT covers host-originated traffic, including loopback. The sysctls apply to the host network namespace; they do not change existing container namespaces. Container-local traffic and datapaths bypassing host netfilter, such as macvlan/ipvlan or some BPF/XDP configurations, are outside this mitigation's coverage. BPF-driven request migration is also not ruled out by the sysctl. Kernel updates remain necessary. - -Disabling MPTCP can affect applications explicitly requiring MPTCP. Blocking IP options can affect NetLabel/CIPSO and other specialised networks. Canary these workloads before rollout. - -Persistent files: - -- `/usr/local/lib/dappnode/mitigate_cve_2026_98432.sh`: standalone install/apply/status/remove utility. -- `/var/lib/dappnode/cve-2026-98432/`: original settings, lock and explicit-removal sentinel. -- `/etc/sysctl.d/99-dappnode-cve-2026-98432.conf`: settings for keys present at install time. -- `/etc/systemd/system/dappnode-cve-2026-98432.{service,timer}`: boot application and one-minute repair/check interval. -- `/usr/src/dappnode/DNCORE/security/cve-2026-98432.status`: last operation result for DappManager. - -The timer repairs accidental removal of these two rules; a firewall reload may still create an exposure window before the next run. DappManager checks live state rather than trusting a previous successful status file. No claim is made about exploit resistance. - -## Developer release steps - -1. Review the companion DappManager PR and this Core PR. Keep both draft until canary results are recorded. Existing original worktrees were not modified by this work. -2. Run the disposable Linux tests: - - ```sh - docker build -t dappnode-cve-mitigation-test -f test/Dockerfile . - docker run --rm --privileged dappnode-cve-mitigation-test - docker run --rm dappnode-cve-mitigation-test shellcheck /tests/mitigate.sh /tests/upgrade_014.sh - ``` - - These exercise real netfilter with harmless connections and IPv4 options, including a DNATed network namespace; they do not attempt exploitation. systemctl is a test stub, while generated units are checked by `systemd-analyze verify`. They do not replace a real systemd boot/hardware canary. -3. On representative Ubuntu Dappnodes, with console recovery available, run the new Core build. Cover both architecture families used in the fleet, iptables-nft and iptables-legacy where deployed, WireGuard/OpenVPN, DNS, execution/consensus clients and validator connectivity. Include machines with and without the MPTCP sysctl. Verify real reboot persistence, timer repair after a managed firewall reload, and no duplicate rules after a Core restart. -4. Publish a DappManager patch release using its [Main workflow](https://github.com/dappnode/DNP_DAPPMANAGER/actions/workflows/main.yml) from the reviewed release branch. Use `bump=patch` and record the actual resulting version; do not guess a version from the development manifest. -5. Publish a Core patch release using its [Main workflow](https://github.com/dappnode/DNP_CORE/actions/workflows/main.yml). Set `core=patch`, use the newly published DappManager dependency version, and preserve all other intended dependency versions. This workflow publishes the package; merging alone does not distribute it. Review the generated `update-versions` PR as usual. -6. Announce: **“Update Dappnode Core to version to apply a temporary mitigation on Ubuntu. This reduces exposure; an official kernel update is still required. No reboot is needed to activate this temporary mitigation.”** Users who disabled automatic Core updates must update manually. Existing automatic Core updates include a 24-hour delay. Fresh script/ISO installs do not necessarily include the Core migration container; do not claim installer coverage without explicitly ensuring the new Core update runs. -7. Verify the installed state on canaries and watch DappManager for failed/unverified mitigation alerts. Users with host scripts disabled need a separate operator-managed response. DappManager's generic host-update button does not install this mitigation and does not select proposed kernel packages. - -## Host verification and recovery - -Run these on the Linux Dappnode host, not inside DappManager: - -```sh -sudo bash /usr/local/lib/dappnode/mitigate_cve_2026_98432.sh status -sudo systemctl status dappnode-cve-2026-98432.timer -sudo journalctl -u dappnode-cve-2026-98432.service -sudo iptables -t raw -S PREROUTING -sudo iptables -t raw -S OUTPUT -sudo sysctl net.mptcp.enabled net.ipv4.tcp_migrate_req -``` - -`mitigated` means the two live firewall rules and supported host sysctls are present. It does not indicate kernel patch status. A missing sysctl is expected on some kernels. A failed install retains its snapshots so rerunning the installed utility's `install` command, or rerunning the new Core container if the utility was not copied yet, can recover without losing original settings. The script's stderr and Core logs explain failures such as missing iptables/`xt_u32` support. - -To undo the mitigation (also usable immediately for operational problems): - -```sh -sudo bash /usr/local/lib/dappnode/mitigate_cve_2026_98432.sh remove -``` - -This disables its units, deletes only its tagged firewall rules and dedicated config files, and restores recorded sysctl values unless a later administrator change moved the live value away from zero. It leaves a removal sentinel so subsequent Core runs respect the rollback. If rollback fails, retain the saved state and retry `remove`; `status` stays failed until removal completes. To intentionally re-enable after a successful removal: - -```sh -sudo rm /var/lib/dappnode/cve-2026-98432/removed -sudo bash /usr/local/lib/dappnode/mitigate_cve_2026_98432.sh install -``` - -## When Canonical publishes the official update - -1. Check Canonical's tracker and the actual APT candidate for the host release and kernel flavour. Apply the released kernel through **System → Host → Update and upgrade** in the new DappManager (or normal operator-managed package updates). -2. Reboot at the operator's chosen time. Confirm `uname -r` and the running image package version against the appropriate vendor fixed version. Check networking and validator recovery. A successful APT command or absence of `/run/reboot-required` is not sufficient evidence of this CVE being fixed. -3. Once the running kernel is verified fixed, run the removal command above. The current release deliberately does not guess when it is safe to remove the workaround automatically. Plan a later verified cleanup migration for the fleet. - -## Sources - -- [Canonical advisory and release status](https://ubuntu.com/blog/fixes-available-in-proposed-pocket-for-cve-2026-98432) -- [Ubuntu CVE tracker and filtering limitations](https://ubuntu.com/security/CVE-2026-98432) -- [Akamai research and temporary sysctls](https://www.akamai.com/blog/security-research/cve-2026-98432-remote-uaf-linux-kernels-tcp-stack) -- [AWS security bulletin with iptables example](https://aws.amazon.com/security/security-bulletins/2026-160-aws/) -- [Red Hat advisory and incomplete filtering protection](https://access.redhat.com/security/vulnerabilities/RHSB-2026-016) -- [Linux MPTCP sysctl namespace semantics](https://docs.kernel.org/networking/mptcp-sysctl.html) diff --git a/src/entrypoint.sh b/src/entrypoint.sh index d93d9a8..a82de33 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -2,7 +2,6 @@ STATUS_CHECK_DELAY=1m CONTAINER_NAME=DAppNodeCore-dappmanager.dnp.dappnode.eth DAPPMANAGER_YML=/usr/src/dappnode/DNCORE/docker-compose-dappmanager.yml -upgrades_failed=0 if [[ "$DISABLE_HOST_SCRIPTS" == "true" ]]; then echo "DISABLE_HOST_SCRIPTS is set to true, skipping host scripts copy and upgrades execution" @@ -19,10 +18,7 @@ else # Apply all local upgrades for filename in ./upgrades/upgrade_*.sh; do echo "Applying upgrade ${filename}..." - if ! sh "${filename}"; then - echo "ERROR: upgrade ${filename} failed" >&2 - upgrades_failed=1 - fi + sh "${filename}" done fi @@ -44,7 +40,4 @@ elif [[ $RUNNING_IMAGE != $YML_IMAGE ]];then echo "YML_VERSION=${YML_VERSION} - RUNNING_VERSION=${RUNNING_VERSION}" docker-compose -f $DAPPMANAGER_YML up -d <&- fi -fi - -# Restore DappManager above even if a host migration failed, then expose failure. -exit "$upgrades_failed" +fi \ No newline at end of file diff --git a/test/Dockerfile b/test/Dockerfile deleted file mode 100644 index d5b7502..0000000 --- a/test/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM ubuntu:24.04 -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - iptables iproute2 procps python3 systemd shellcheck && rm -rf /var/lib/apt/lists/* -WORKDIR /tests -COPY src/scripts/mitigate_cve_2026_98432.sh /tests/mitigate.sh -COPY src/upgrades/upgrade_014.sh /tests/upgrade_014.sh -COPY src/entrypoint.sh /tests/entrypoint.sh -COPY test/test_mitigation.py /tests/test_mitigation.py -ENV DAPPNODE_CVE_TEST_CONTAINER=1 -CMD ["python3", "-m", "unittest", "-v", "test_mitigation.py"] diff --git a/test/test_mitigation.py b/test/test_mitigation.py deleted file mode 100644 index 25a5d16..0000000 --- a/test/test_mitigation.py +++ /dev/null @@ -1,163 +0,0 @@ -"""Harmless packet and lifecycle tests; run only in the disposable privileged container.""" -import os -from pathlib import Path -import shutil -import socket -import subprocess -import time -import tempfile -import unittest - -SCRIPT = "/tests/mitigate.sh" -STATE = Path("/var/lib/dappnode/cve-2026-98432") -RULE = ["-p", "tcp", "-m", "u32", "--u32", "0>>24&0x0f=6:15", "-m", "comment", "--comment", "dappnode-cve-2026-98432", "-j", "DROP"] - - -def run(*args, check=True, env=None): - return subprocess.run(args, text=True, capture_output=True, check=check, env=env) - - -@unittest.skipUnless(os.environ.get("DAPPNODE_CVE_TEST_CONTAINER") == "1" and Path("/.dockerenv").exists(), "disposable privileged Docker container required") -class MitigationTests(unittest.TestCase): - def setUp(self): - for chain in ("PREROUTING", "OUTPUT"): - while run("iptables", "-t", "raw", "-C", chain, *RULE, check=False).returncode == 0: - run("iptables", "-t", "raw", "-D", chain, *RULE) - shutil.rmtree(STATE, ignore_errors=True) - Path("/usr/src/dappnode/DNCORE/security").mkdir(parents=True, exist_ok=True) - Path("/usr/src/dappnode/DNCORE/security/cve-2026-98432.status").unlink(missing_ok=True) - # Exercise systemd wiring without needing PID 1 to be systemd in Docker. - Path("/usr/local/bin/systemctl").write_text('#!/bin/sh\nprintf "%s\\n" "$*" >> /tmp/systemctl-calls\nexit 0\n') - Path("/usr/local/bin/systemctl").chmod(0o755) - Path("/usr/local/bin/sysctl").unlink(missing_ok=True) - run("/usr/sbin/sysctl", "-w", "net.ipv4.tcp_migrate_req=1") - - def install(self): - result = run("bash", SCRIPT, "install") - self.assertIn("Temporary mitigation installed", result.stdout) - self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "mitigated") - - def test_lifecycle_reapply_detection_and_rollback(self): - self.install() - original = STATE / "net.ipv4.tcp_migrate_req.original" - self.assertEqual(original.read_text().strip(), "1") - self.assertEqual(run("sysctl", "-n", "net.ipv4.tcp_migrate_req").stdout.strip(), "0") - # Missing MPTCP is supported; never fabricate a sysctl on such kernels. - if run("sysctl", "-n", "net.mptcp.enabled", check=False).returncode: - self.assertNotIn("net.mptcp.enabled", Path("/etc/sysctl.d/99-dappnode-cve-2026-98432.conf").read_text()) - run("bash", SCRIPT, "install") - self.assertEqual(original.read_text().strip(), "1") - self.assertEqual(run("iptables", "-t", "raw", "-S").stdout.count("dappnode-cve-2026-98432"), 2) - run("systemd-analyze", "verify", "/etc/systemd/system/dappnode-cve-2026-98432.service", "/etc/systemd/system/dappnode-cve-2026-98432.timer") - run("iptables", "-t", "raw", "-D", "PREROUTING", *RULE) - self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "failed") - run("bash", SCRIPT, "apply") - self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "mitigated") - run("bash", SCRIPT, "remove") - self.assertEqual(run("sysctl", "-n", "net.ipv4.tcp_migrate_req").stdout.strip(), "1") - self.assertNotIn("dappnode-cve-2026-98432", run("iptables", "-t", "raw", "-S").stdout) - self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "removed") - run("bash", SCRIPT, "remove") # Idempotent removal. - run("bash", SCRIPT, "install") # Core replay respects an explicit rollback. - self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "removed") - - def test_failed_apply_is_not_reported_as_mitigated(self): - Path("/usr/local/bin/sysctl").write_text('#!/bin/sh\ncase "$*" in "-w net.ipv4.tcp_migrate_req=0") exit 1;; esac\nexec /usr/sbin/sysctl "$@"\n') - Path("/usr/local/bin/sysctl").chmod(0o755) - result = run("bash", SCRIPT, "install", check=False) - self.assertNotEqual(result.returncode, 0) - self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "failed") - self.assertTrue((STATE / "net.ipv4.tcp_migrate_req.original").exists()) - Path("/usr/local/bin/sysctl").unlink() - run("bash", SCRIPT, "install") # Retry after a partial failure. - self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "mitigated") - - def test_host_forwarded_and_loopback_packets(self): - self.install() - servers = [] - try: - run("ip", "netns", "add", "peer") - run("ip", "netns", "add", "backend") - for namespace, subnet in (("peer", "10.90.0"), ("backend", "10.91.0")): - host = "cv-" + namespace - run("ip", "link", "add", host, "type", "veth", "peer", "name", "eth0", "netns", namespace) - run("ip", "addr", "add", subnet + ".1/24", "dev", host) - run("ip", "link", "set", host, "up") - run("ip", "-n", namespace, "addr", "add", subnet + ".2/24", "dev", "eth0") - run("ip", "-n", namespace, "link", "set", "eth0", "up") - run("ip", "-n", namespace, "link", "set", "lo", "up") - run("ip", "-n", namespace, "route", "add", "default", "via", subnet + ".1") - run("sysctl", "-w", "net.ipv4.ip_forward=1") - # Model Docker's published port: incoming TCP is DNATed to another namespace. - nat = ["-i", "cv-peer", "-p", "tcp", "--dport", "18081", "-j", "DNAT", "--to-destination", "10.91.0.2:18081"] - run("iptables", "-t", "nat", "-A", "PREROUTING", *nat) - servers.append(subprocess.Popen(["python3", "-m", "http.server", "18080", "--bind", "0.0.0.0"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)) - servers.append(subprocess.Popen(["ip", "netns", "exec", "backend", "python3", "-m", "http.server", "18081", "--bind", "0.0.0.0"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)) - time.sleep(0.5) - for prefix, address, port in ((["ip", "netns", "exec", "peer"], "10.90.0.1", 18080), (["ip", "netns", "exec", "peer"], "10.90.0.1", 18081), ([], "127.0.0.1", 18080)): - for options in (False, True): - code = f'''import socket -s=socket.socket(); s.settimeout(1) -s.setsockopt(socket.IPPROTO_TCP, socket.TCP_MAXSEG, 1200) -if {options}: s.setsockopt(socket.IPPROTO_IP, socket.IP_OPTIONS, bytes([1,1,1,0])) -try: - s.connect(({address!r}, {port})); s.sendall(b"GET / HTTP/1.0\\r\\n\\r\\n"); data=s.recv(100); assert data -except (TimeoutError, OSError): - raise SystemExit(1) -''' - result = run(*prefix, "python3", "-c", code, check=False) - self.assertEqual(result.returncode, 1 if options else 0, result.stderr) - counters = run("iptables", "-t", "raw", "-L", "-n", "-v", "-x").stdout - drops = [int(line.split()[0]) for line in counters.splitlines() if "dappnode-cve-2026-98432" in line] - self.assertEqual(len(drops), 2) - self.assertTrue(all(count > 0 for count in drops), counters) - finally: - for server in servers: - server.terminate() - server.wait() - for namespace in ("peer", "backend"): - run("ip", "netns", "del", namespace, check=False) - run("iptables", "-t", "nat", "-D", "PREROUTING", *nat, check=False) if "nat" in locals() else None - - def test_persistence_failure_stays_visible_even_when_rules_are_live(self): - Path("/usr/local/bin/systemctl").write_text('#!/bin/sh\nexit 1\n') - result = run("bash", SCRIPT, "install", check=False) - self.assertNotEqual(result.returncode, 0) - self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "failed") - - def test_entrypoint_starts_manager_before_reporting_upgrade_failure(self): - with tempfile.TemporaryDirectory() as directory: - root = Path(directory) - for child in ("upgrades", "scripts", "deb", "bin"): - (root / child).mkdir() - (root / "upgrades/upgrade_014.sh").write_text("exit 17\n") - (root / "scripts/noop.sh").write_text("exit 0\n") - (root / "packages-content-hash.csv").write_text("") - for name, body in { - "sleep": "exit 0", - "docker": "echo false", - "docker-compose": "echo manager-started" - }.items(): - stub = root / "bin" / name - stub.write_text("#!/bin/sh\n" + body + "\n") - stub.chmod(0o755) - Path("/usr/src/dappnode/DNCORE/docker-compose-dappmanager.yml").write_text("image: example:1\n") - env = dict(os.environ, PATH=str(root / "bin") + ":" + os.environ["PATH"]) - result = subprocess.run(["bash", "/tests/entrypoint.sh"], cwd=root, env=env, capture_output=True, text=True) - self.assertEqual(result.returncode, 1) - self.assertIn("manager-started", result.stdout) - self.assertIn("upgrade_014.sh failed", result.stderr) - env["DISABLE_HOST_SCRIPTS"] = "true" - result = subprocess.run(["bash", "/tests/entrypoint.sh"], cwd=root, env=env, capture_output=True, text=True) - self.assertEqual(result.returncode, 0) - - def test_non_ubuntu_is_skipped(self): - path = Path("/etc/os-release") - original = path.read_text() - try: - path.write_text('ID=debian\nVERSION_CODENAME=bookworm\n') - run("bash", SCRIPT, "install") - self.assertEqual(run("bash", SCRIPT, "status").stdout.strip(), "not-applicable") - self.assertNotIn("dappnode-cve-2026-98432", run("iptables", "-t", "raw", "-S").stdout) - finally: - path.write_text(original) From 70b84120adef3d80b8ff7683520a4766a8e87de2 Mon Sep 17 00:00:00 2001 From: Marketen Date: Tue, 3 Nov 2026 12:22:16 +0100 Subject: [PATCH 4/5] fix: persist mitigation at boot without periodic polling --- src/scripts/mitigate_cve_2026_98432.sh | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/scripts/mitigate_cve_2026_98432.sh b/src/scripts/mitigate_cve_2026_98432.sh index 17bd38d..b0f22cc 100755 --- a/src/scripts/mitigate_cve_2026_98432.sh +++ b/src/scripts/mitigate_cve_2026_98432.sh @@ -51,7 +51,7 @@ status() { apply() { [[ ! -f "$state_dir/removed" ]] || return 0 local key value chain - # Record original values once. Repeated boot/timer runs never replace them. + # Record original values once. Repeated applications never replace them. for key in "${keys[@]}"; do if value=$(sysctl -n "$key" 2>/dev/null); then [[ "$value" == 0 || "$value" == 1 ]] @@ -82,6 +82,11 @@ install() { if [[ ${ID:-} != ubuntu ]]; then write_status not-applicable; return 0; fi command -v iptables >/dev/null command -v sysctl >/dev/null + # Remove the periodic checker if an earlier draft was installed on a canary. + if [[ -f "$unit_dir/$unit.timer" ]]; then + systemctl disable --now "$unit.timer" + rm -f "$unit_dir/$unit.timer" + fi # Make rollback available before applying any network changes. mkdir -p "$(dirname "$script_path")" if [[ $(readlink -f "$0") != "$script_path" ]]; then command install -m 755 "$0" "$script_path"; fi @@ -103,28 +108,14 @@ Conflicts=shutdown.target [Service] Type=oneshot +RemainAfterExit=yes ExecStart=/bin/bash $script_path apply [Install] WantedBy=multi-user.target -UNIT - cat > "$unit_dir/$unit.timer" < Date: Tue, 3 Nov 2026 12:49:55 +0100 Subject: [PATCH 5/5] fix: keep iptables predicate output out of mitigation status --- src/scripts/mitigate_cve_2026_98432.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scripts/mitigate_cve_2026_98432.sh b/src/scripts/mitigate_cve_2026_98432.sh index b0f22cc..cfbc989 100755 --- a/src/scripts/mitigate_cve_2026_98432.sh +++ b/src/scripts/mitigate_cve_2026_98432.sh @@ -22,7 +22,7 @@ write_status() { check_rules() { local chain key value for chain in PREROUTING OUTPUT; do - iptables -w 5 -t raw -C "$chain" "${rule[@]}" 2>/dev/null || return 1 + iptables -w 5 -t raw -C "$chain" "${rule[@]}" >/dev/null 2>&1 || return 1 done for key in "${keys[@]}"; do if value=$(sysctl -n "$key" 2>/dev/null); then @@ -63,7 +63,7 @@ apply() { # PREROUTING covers host INPUT and normal Docker bridge/DNAT forwarding. # OUTPUT also covers host-originated traffic and loopback. Never flush rules. for chain in PREROUTING OUTPUT; do - if ! iptables -w 5 -t raw -C "$chain" "${rule[@]}" 2>/dev/null; then + if ! iptables -w 5 -t raw -C "$chain" "${rule[@]}" >/dev/null 2>&1; then iptables -w 5 -t raw -I "$chain" 1 "${rule[@]}" fi done @@ -128,7 +128,7 @@ remove() { for chain in PREROUTING OUTPUT; do # Check table access separately: a missing rule is OK, permission errors aren't. iptables -w 5 -t raw -S "$chain" >/dev/null - while iptables -w 5 -t raw -C "$chain" "${rule[@]}" 2>/dev/null; do + while iptables -w 5 -t raw -C "$chain" "${rule[@]}" >/dev/null 2>&1; do iptables -w 5 -t raw -D "$chain" "${rule[@]}" done done