XNU PF_ROUTE RTA_GENMASK Heap Buffer Overflow (CVE-2026-20698)
by Somair Ansar (Somisomair) — independently discovered; CVE credited to DARKNAVY as original reporter · 2026-07-05
- Severity
- High
- CVE
- CVE-2026-20698
- Category
- binary
- Affected product
- XNU kernel routing socket subsystem (PF_ROUTE, bsd/net/rtsock.c / bsd/net/radix.c)
- Affected versions
- iOS/iPadOS < 26.4, macOS < 26.4 (tested on iPhone 17 Pro Max, iOS 26.3.1, and additional devices on iOS 26.1); fixed in iOS/iPadOS 26.4
- Disclosed
- 2026-07-05
- Patch status
- patched
Tags
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-03 |
| Author / Researcher | Somair Ansar (Somisomair) — independently discovered; CVE credited to DARKNAVY as original reporter |
| CVE / Advisory | CVE-2026-20698 |
| Category | binary |
| Severity | High |
| CVSS Score | Not specified in source |
| Status | PoC |
| Tags | xnu, kernel, ios, macos, pf_route, routing-socket, heap-overflow, radix-tree, kernel-panic, bounds-safety |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | XNU kernel routing socket subsystem (PF_ROUTE, bsd/net/rtsock.c / bsd/net/radix.c) |
| Versions Affected | iOS/iPadOS < 26.4, macOS < 26.4 (tested on iPhone 17 Pro Max, iOS 26.3.1, and additional devices on iOS 26.1); fixed in iOS/iPadOS 26.4 |
| Language / Platform | C, targets the XNU kernel via a raw PF_ROUTE socket |
| Authentication Required | No |
| Network Access Required | No (local, unprivileged process; no entitlements required) |
Summary
XNU’s routing socket implementation processes RTM_GET messages carrying an RTA_GENMASK sockaddr through rn_addmask(), which copies the supplied genmask into a fixed, address-family-dependent radix-tree node buffer without validating that the attacker-controlled sa_len actually fits. Because socket(PF_ROUTE, SOCK_RAW, 0) and RTM_GET are both available to fully unprivileged, unsandboxed-relevant apps, any local process can trigger an out-of-bounds write. On current iOS builds this is caught by the -fbounds-safety compiler instrumentation and converted into a deterministic kernel panic rather than silent corruption; the repo documents five crash variants across different address families (AF_UNIX, AF_LINK, AF_INET6, AF_INET, AF_UNSPEC), two of which (AF_UNIX, AF_LINK) overflow at the very minimum possible sockaddr length, meaning there is no valid input for those families that avoids the bug.
Vulnerability Details
Root Cause
route_output() passes a user-supplied RTA_GENMASK sockaddr to rn_addmask(), which stores it into a radix-tree node key buffer sized per address family without checking that sa_len fits that buffer, producing a heap out-of-bounds write when an oversized genmask is supplied.
Attack Vector
- Open an unprivileged raw routing socket:
socket(PF_ROUTE, SOCK_RAW, 0). - Construct a routing message (
rt_msghdr) of typeRTM_GETwithrtm_addrs = RTA_DST | RTA_GENMASK. - Append a valid destination sockaddr, then append a genmask sockaddr whose
sa_lenexceeds the buffer XNU allocates for that address family (e.g. anAF_INET6mask withsa_len = 48). write()the message to the routing socket;route_output()→rn_addmask()copies the oversized mask into the undersized radix-tree buffer, corrupting adjacent heap memory (or, on-fbounds-safety-instrumented kernels, immediately tripping a bounds check and panicking).
Impact
Fully unprivileged, single-syscall, 100%-reliable local denial of service (instant kernel panic/reboot) from any process including sideloaded/App Store-distributable apps; on kernels without bounds-safety instrumentation the same out-of-bounds write is a plausible kernel heap-corruption primitive for further exploitation.
Environment / Lab Setup
Target: iOS 26.3.1 or earlier / macOS < 26.4, physical device
Attacker: clang/Xcode toolchain (xcrun -sdk iphoneos clang), ldid for ad hoc signing, ability to deploy an unsigned/sideloaded binary or app to the target
Proof of Concept
PoC Script
See
pf_route_crash.c(minimal crash trigger),variant_probe.c/family_probe.c/single_family.c(address-family variant enumeration),genmask_escalate.c(escalation analysis),route_26_4_variants.c(post-patch verification), andvariant_26_4_test.m(iOS app harness) in this folder.
| |
The minimal PoC opens a PF_ROUTE socket, builds an RTM_GET message with a deliberately oversized AF_INET6 genmask sockaddr, and writes it to the socket; on an affected kernel the device panics and reboots immediately. The variant scripts sweep multiple address families to map out which trigger the overflow and at what minimum length.
Detection & Indicators of Compromise
panic(cpu 0 caller 0xfffffe004e56c79c): Bounds safety trap at pc 0xfffffe004dfc4024, ...
esr: 0x00000000f2005519 far: 0x00000002899e6958
Kernel version: Darwin Kernel Version 25.3.0; root:xnu-12377.82.2~13/RELEASE_ARM64_T8150
Panicked task pid ...: <process name>
Signs of compromise:
- Kernel panic logs showing a “Bounds safety trap” (BRK/ESR
0xf2005519-style fault) originating from routing-socket / radix-tree code. - A local process observed opening a raw
PF_ROUTEsocket and issuingRTM_GETmessages withRTA_GENMASKimmediately prior to a panic. - Repeated, otherwise-unexplained device reboots correlated with launching a specific unprivileged app.
Remediation
| Action | Detail |
|---|---|
| Primary fix | Update to iOS 26.4 / iPadOS 26.4 or later, which validates sa_len and returns ENOBUFS instead of processing an oversized genmask |
| Interim mitigation | Avoid running untrusted third-party apps on affected builds; there is no user-facing configuration mitigation since PF_ROUTE access requires no entitlement |
References
Notes
Mirrored from https://github.com/Somisomair/CVE-2026-20698-PF_ROUTE-Heap-Overflow on 2026-07-05.
| |