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

wep_setkey missing upper-bound key length validation allows stack overflow in RC4 key buffer

Summary

wep_setkey (:122-126): return k->wk_keylen >= 40/NBBY ONLY lower bound no upper. rc4key[IEEE80211_WEP_IVLEN+IEEE80211_KEYBUF_SIZE]=3+16=19B stack (:334,417). memcpy(rc4key+3,key->wk_key,key->wk_keylen) (:346,429): if wk_keylen>16 writes past rc4key[19] overflow stack (S[256]+icv[4]+frame ptr/ret addr adjacent). Compare ccmp_setkey/tkip_setkey gate on ==16 exact. Current mitigation: ioctl paths ieee80211_ioctl.c:1216-1217,2711-2712 clamp wk_keylen<=16 before crypto_setkey so no current userspace path triggers. Defense-in-depth gap inconsistent contract enforcement. Requires CAP_NET_WIFI root to install keys. Fix: if(keylen<40/NBBY||keylen>IEEE80211_KEYBUF_SIZE) return 0.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-0694 Β· 5 files
FileTypeDescriptionSize
fix.diff suggested-fix Add the upper-bound check (<= IEEE80211_KEYBUF_SIZE) in wep_setkey. 436 B view raw
VERDICT.md verdict source-confirmation + fix 1.1 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-0694 β€” Low-severity source-confirmation

Verdict: REPRODUCED

Impact: panic Confidence: likely

Kernel ref: netproto/802_11/wlan_wep/ieee80211_crypto_wep.c:122

Mechanism / why

Source-confirmed: wep_setkey only checks wk_keylen>=40/NBBY (no upper bound); the 19-byte rc4key stack buffer can overflow on an oversized keylen. wlan_wep (GENERIC).

Add the upper-bound check (<= IEEE80211_KEYBUF_SIZE) in wep_setkey.

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-0694 [REPRODUCED] - netproto/802_11/wlan_wep/ieee80211_crypto_wep.c:122

PoC changes

fix.diff present in findings/poc/DF-0694/; batched into ../_batch_low/combined_all.patch

Verified recommended fix

Add the upper-bound check (<= IEEE80211_KEYBUF_SIZE) in wep_setkey.

Verdict

Source-confirmed: wep_setkey only checks wk_keylen>=40/NBBY (no upper bound); the 19-byte rc4key stack buffer can overflow on an oversized keylen. wlan_wep (GENERIC).