β¬’ DragonFlyBSD Kernel Audit
← triage Β· dashboard
DF-0642

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 (SIOCS80211 requires caps_priv_check_self(SYSCAP_NONET_WIFI) per ieee80211_ioctl.c:3472, root-equivalent).
  • Preconditions: a wireless vap interface that is not in INIT state (has been brought UP, even without association; monitor mode or a vap in SCAN state suffices) and ic_nrunning != 0.
  • Impact: immediate kernel panic β€” guaranteed local DoS. The heap corruption is real but the synchronous page-fault in memcpy precedes any use of the corrupted state, so reliable code execution is speculative.

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

Timeline

  • 2026-07-02 Discovered during automated DragonFlyBSD kernel security audit.
  • 2026-07-02 Reported to DragonFlyBSD security contact (pending).

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-0642 Β· 5 files
FileTypeDescriptionSize
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
VERDICT.md verdict source-confirmation + fix
↓ download 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).

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

fixed
baseline reproduced→ patch + rebuild →patched clean

combined 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
↓ fix.diffDragonFly 6.5-DEVELOPMENT #1: Thu Jul 23 06:52:07 UTC 2026

Confirmed kernel references

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).