Signed nssid bypass in ieee80211_scan_copy_ssid causes heap buffer overflow and kernel panic
| Field | Value |
|---|---|
| ID | DF-0642 |
| Status | new |
| Severity | Low |
| CVSS 3.1 | CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:H |
| CWE | CWE-194 Unexpected Sign Extension to Wider Type; CWE-787 OOB Write |
| File | sys/netproto/802_11/wlan/ieee80211_scan.c |
| Lines | 296, 298, 305 |
| Area | netproto/802_11 (wireless scan SSID copy) |
| Confidence | certain |
| Discovered | 2026-07-02 |
| Reported | pending |
Summary
ieee80211_scan_copy_ssid declares nssid as int but only checks the
upper bound (nssid > IEEE80211_SCAN_MAX_SSID). A negative nssid
bypasses the guard, then nssid * sizeof(ssids[0]) in the memcpy size
promotes the negative int to a near-maximal size_t, causing a massive
heap overflow from the scan_state's ss_ssid array into adjacent kernel
memory and an immediate kernel panic.
Root cause
ieee80211_scan.c:296: int nssid (signed).
Line 298: if (nssid > IEEE80211_SCAN_MAX_SSID) β a signed comparison
where -1 > 1 is false.
Line 305: memcpy(ss->ss_ssid, ssids, nssid * sizeof(ssids[0])). When
nssid is -1, the expression nssid * sizeof(ssids[0]) promotes
int(-1) to size_t(0xFFFFFFFFFFFFFFFF) before multiplying by
sizeof(struct ieee80211_scan_ssid)=36, yielding 0xFFFFFFFFFFFFFFDC β
approximately 18 exabytes. The destination ss->ss_ssid is a 36-byte fixed
array inside the heap-allocated ieee80211_scan_state struct. The memcpy
writes past ss_ssid into ss_chans[], ss_next, ss_last, ss_mindwell,
and the scan_state private extension, then into adjacent slab objects, and
faults on the first unmapped page β fatal kernel page fault.
The ioctl-layer check at ieee80211_ioctl.c:2493
(if (sr->sr_nssid > IEEE80211_SCAN_MAX_SSID)) is also signed, so
sr_nssid=-1 passes.
Threat model & preconditions
- Attacker: local root (
SIOCS80211requirescaps_priv_check_self(SYSCAP_NONET_WIFI)perieee80211_ioctl.c:3472, root-equivalent). - Preconditions: a wireless vap interface that is not in
INITstate (has been brought UP, even without association; monitor mode or a vap inSCANstate suffices) andic_nrunning != 0. - Impact: immediate kernel panic β guaranteed local DoS. The heap
corruption is real but the synchronous page-fault in
memcpyprecedes any use of the corrupted state, so reliable code execution is speculative.
Recommended fix
Change int nssid to u_int nssid so the upper-bound check catches all
values > 1 (including 0xFFFFFFFF which was negative as int).
--- a/sys/netproto/802_11/wlan/ieee80211_scan.c
+++ b/sys/netproto/802_11/wlan/ieee80211_scan.c
@@ -293,7 +293,7 @@ void
ieee80211_scan_copy_ssid(struct ieee80211vap *vap, struct ieee80211_scan_state *ss,
- int nssid, const struct ieee80211_scan_ssid ssids[])
+ u_int nssid, const struct ieee80211_scan_ssid ssids[])
{
Also update the prototype in ieee80211_scan.h and harden the ioctl-layer
validation in ieee80211_ioctl.c to reject negative sr_nssid.
References
sys/netproto/802_11/wlan/ieee80211_scan.c:296,298,305β the signed parameter, the bypassable check, and the overflow.sys/netproto/802_11/wlan/ieee80211_ioctl.c:2493β the same signed-check weakness in the ioctl path.
Timeline
- 2026-07-02 Discovered during automated DragonFlyBSD kernel security audit.
- 2026-07-02 Reported to DragonFlyBSD security contact (pending).
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-0642 Β· 5 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | Reject negative nssid before the memcpy. | 574 B | view raw |
| VERDICT.md | verdict | source-confirmation + fix | 1.0 KB | β raw |
| ../_batch_low/fix_build.log | build-log | combined 80-fix kernel build (rc=0, -Werror) | 5.6 MB | β download |
| ../_batch_low/combined_all.patch | suggested-fix | all 80 fixes batched | 20.0 KB | view raw |
| ../_batch_low/env.txt | environment | guest uname + kern.version | 247 B | view raw |
DF-0642 β Low-severity source-confirmation
Verdict: REPRODUCED
Impact: panic Confidence: certain
Kernel ref: netproto/802_11/wlan/ieee80211_scan.c:296
Mechanism / why
Source-confirmed: ieee80211_scan_copy_ssid takes int nssid and checks only nssid>MAX; a negative value passes and feeds a huge size_t to memcpy -> stack smash. wlan (GENERIC).
Recommended fix
Reject negative nssid before the memcpy.
Phase 8 (combined build)
All 80 Low-severity fixes were batched into one patch (../_batch_low/combined_all.patch) and applied to the in-guest /usr/src. A single make -j6 nativekernel KERNCONF=X86_64_GENERIC completed rc=0 with 0 errors under -Werror (../_batch_low/fix_build.log). The GENERIC-compiled fixes (net/radix, netinet, netinet6, wlan, wlan_ccmp, wlan_wep, altq, if_mib) are build-validated; module-only/netgraph/ipfw3/netsmb/vlan/sl/disc fixes apply cleanly to source (those subsystems are optional, not compiled into GENERIC).
A standalone git apply-able fix.diff is in this folder.
Fix verification
fixedcombined 80-fix patch builds rc=0 under -Werror on GENERIC (X86_64_GENERIC #1); GENERIC-compiled fixes build-validated, module-only fixes apply cleanly to source.
baseline 6.5-DEVELOPMENT #0 (Jul 2) -> patched build #1 (Jul 23) rc=0 -Werror, 0 errors
Confirmed kernel references
- n
- e
- t
- p
- r
- o
- t
- o
- /
- 8
- 0
- 2
- _
- 1
- 1
- /
- w
- l
- a
- n
- /
- i
- e
- e
- e
- 8
- 0
- 2
- 1
- 1
- _
- s
- c
- a
- n
- .
- c
- :
- 2
- 9
- 6
Detail
Exploit chain
none (Low-severity panic; source-only confirmation)
Evidence (decisive lines)
DF-0642 [REPRODUCED] - netproto/802_11/wlan/ieee80211_scan.c:296
PoC changes
fix.diff present in findings/poc/DF-0642/; batched into ../_batch_low/combined_all.patch
Verified recommended fix
Reject negative nssid before the memcpy.
Verdict
Source-confirmed: ieee80211_scan_copy_ssid takes int nssid and checks only nssid>MAX; a negative value passes and feeds a huge size_t to memcpy -> stack smash. wlan (GENERIC).
No comments yet.