You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] wireless/ieee802154/i8shark: received 802.15.4 frame.length/frame.offset used unvalidated to size memcpy into the exact-sized zepframe[159] stack buffer (radio-triggered stack overflow) #3950
i8shark puts the radio into promiscuous mode and reads received 802.15.4 frames from the MAC
character driver, then copies the frame payload into a fixed stack buffer sized to the exact
theoretical maximum (zero margin), using the device-reported frame.length/frame.offset
without any validation.
frame.length and frame.offset are filled by the kernel MAC driver straight from the received
over-the-air frame (rx->length = io_len + fcslen on the promiscuous branch); neither the driver
nor the app clamps length to IEEE802154_MAX_PHY_PACKET_SIZE (127). The ZEP header occupies
the first 32 bytes, so the max written index is 32 + frame.length - 1. A full PSDU plus FCS
(length = io_len + fcslen, e.g. 127 + 2 = 129) gives index 160 → stack OOB write past zepframe[158]. No bound check (not even DEBUGASSERT) guards frame.length/frame.offset.
Two additional, config-gated sink variants are worse:
XBEE app-header variant (CONFIG_IEEE802154_I8SHARK_XBEE_APPHDR): signed underflow —
frame.length - frame.offset - 2 is an int; a short/malformed frame with offset + 2 > length yields a negative value → huge size_t in memcpy → massive OOB.
359frame.length-=fcslen; /* underflows to ~254 if length < fcslen */
Any device transmitting an 802.15.4 frame within radio range controls these bytes.
Steps:
Build and run the i8shark sniffer (CONFIG_IEEE802154_I8SHARK) on an 802.15.4 radio.
Transmit a crafted/maximal 802.15.4 frame within range (and, for the variants, a short frame
with offset + 2 > length, or length < fcslen).
The RX loop memcpy writes past zepframe[158] on the stack.
An AddressSanitizer build reports a stack-buffer-overflow WRITE past the 159-byte zepframe.
Expected: a frame with length > 127 or offset > length (or offset + 2 > length in the
XBEE path) is dropped. Actual: the memcpy writes past zepframe[158], or computes a negative/underflowed size.
Suggested fix: immediately after read(), validate frame.length <= IEEE802154_MAX_PHY_PACKET_SIZE, frame.offset <= frame.length, and (XBEE) frame.length >= frame.offset + 2; drop the frame
otherwise.
Activity
wireless/ieee802154/i8shark: validate received frame length and offset