From cb77bdce30ce1f73e20cd3555caa8c9c22375e7a Mon Sep 17 00:00:00 2001 From: VysseCodes <205995085+VysseCodes@users.noreply.github.com> Date: Tue, 1 Dec 2026 18:03:50 -0600 Subject: [PATCH] Car Report: scrub addresses in the iptables dump like the routes The rules only had MACs taken out. Android's own chains (netd's st_mangle_EXEMPT) hold the unit's current mobile-data address and its carrier's servers, so a 2024 Ioniq 5's reports carried its 100.x address in full while the routes showed 100.x.x.x. Public and carrier-NAT addresses in the rules now become a.b.x.x; private ones, ports and policies stay. Checked on that car's real dump: only the 6 st_mangle_EXEMPT lines with those addresses change. net-test.sh covers it. --- CHANGELOG.md | 6 ++++++ core/runtime/java/hmgapi/engine/NetReport.java | 8 +++++--- core/runtime/net-test.sh | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdf81877..7976d209 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +- **The Car Report no longer carries the unit's mobile-data address.** Its iptables dump only had + MAC addresses taken out, and Android's own chains (`st_mangle_EXEMPT`) hold the unit's + current mobile-data address and its carrier's servers. The rules are now scrubbed like the + routes: public and carrier-NAT addresses become `a.b.x.x`, private ones and everything else in + the rules stay. + - **A root service can read its own settings** (`HmgApi.settings()`, `saveSettings()`): the daemon sees such a service as root, so the client names its mod (`HMGAPI_MOD`). diff --git a/core/runtime/java/hmgapi/engine/NetReport.java b/core/runtime/java/hmgapi/engine/NetReport.java index ac710c08..556ea6a2 100644 --- a/core/runtime/java/hmgapi/engine/NetReport.java +++ b/core/runtime/java/hmgapi/engine/NetReport.java @@ -36,9 +36,11 @@ static Map collect(Engine e) { for (String v : new String[] { "4", "6" }) { for (String t : new String[] { "filter", "nat", "mangle" }) { if ("6".equals(v) && "nat".equals(t)) continue; - ipt.put(v + " " + t, macs(run(tool(v), "-t", t, "-S"))); + // scrubbed like the routes: Android's own chains (netd's st_*, bw_*, natctrl_*) hold + // the unit's mobile-data address and its carrier's servers, filled in at runtime + ipt.put(v + " " + t, scrub(run(tool(v), "-t", t, "-S"))); } - ipt.put(v + " counters", macs(run(tool(v), "-L", "-n", "-v", "-x"))); + ipt.put(v + " counters", scrub(run(tool(v), "-L", "-n", "-v", "-x"))); } n.put("iptables", ipt); n.put("interfaces", scrub(run("ip", "-o", "addr", "show"))); @@ -138,7 +140,7 @@ static List services(Engine e) { static final Pattern V4 = Pattern.compile("(? "$ echo 0 > "$R/proc/sys/net/ipv4/ip_forward" cat > "$B/iptables" <<'S' #!/bin/sh -case "$*" in *-S*) printf -- '-P INPUT DROP\n-N WLIST_IN\n-N WL_NCM0_IN\n-A WL_NCM0_IN -p tcp --dport 7000 -j ACCEPT\n' ;; *) echo "Chain INPUT (policy DROP 12 packets, 3400 bytes)" ;; esac +case "$*" in *-S*) printf -- '-P INPUT DROP\n-N WLIST_IN\n-N WL_NCM0_IN\n-A WL_NCM0_IN -p tcp --dport 7000 -j ACCEPT\n-A st_mangle_EXEMPT -d 100.77.12.34/32 -j MARK --set-xmark 0x1/0xffffffff\n-A st_mangle_EXEMPT -d 198.51.100.7/32 -j MARK --set-xmark 0x1/0xffffffff\n-A st_mangle_EXEMPT -d 172.16.172.10/32 -j MARK --set-xmark 0x1/0xffffffff\n' ;; *) printf 'Chain INPUT (policy DROP 12 packets, 3400 bytes)\nChain st_mangle_EXEMPT (1 references)\n 0 0 MARK all -- * * 0.0.0.0/0 100.77.12.34 MARK set 0x1\n' ;; esac S cp "$B/iptables" "$B/ip6tables" cat > "$B/ip" <<'S' @@ -273,6 +273,10 @@ hasnt "report: no MAC from links" "00:1a:2b" "$j" hasnt "report: no phone address (link-local from its MAC)" "1c2d" "$j" has "report: link-local kept as such" "SRC=fe80::[removed]" "$j" hasnt "report: no modem IPv4" "100.77.12.34" "$j" +has "report: Android's mobile-data chain kept, its addresses scrubbed" "-A st_mangle_EXEMPT -d 100.77.x.x/32 -j MARK" "$j" +hasnt "report: no carrier server IPv4 from the rules" "198.51.100.7" "$j" +has "report: private addresses in the rules kept" "172.16.172.10/32" "$j" +has "report: the rules' ports and policies kept" "-A WL_NCM0_IN -p tcp --dport 7000 -j ACCEPT" "$j" has "report: ... cut to its network" "inet 100.77.x.x/30" "$j" hasnt "report: no modem IPv6" "b04e" "$j" has "report: hotspot address kept" "inet 192.168.0.1/24" "$j"