Repository navigation
Description
What happened?
In wled00/udp.cpp, handleNotifications() stores a notifier packet in udpIn[packetSize + 1], then calls parseNotifyPacket(udpIn) without passing the received length. The segment loop takes its segment count from udpIn[39] and stride from udpIn[40]:
unsigned ofs = 41 + i*udpIn[40];
if (ofs + 36 > UDP_IN_MAXSIZE) break;UDP_IN_MAXSIZE is 1472, the maximum allowed datagram size, not the size of this packet. A short packet declaring a segment can therefore pass the check at ofs = 41 while the parser reads beyond the stack buffer. With version 12 and segment options enabled, it may read through udpIn[ofs+35]; with bounds only and version 11, it reads fewer fields but still crosses the buffer. A larger stride can move later reads farther out. The ESP-NOW caller passes a buffer to the same parser without its assembled length as well.
This path requires receiveSegmentOptions or receiveSegmentBounds; both are off by default. It is an out-of-bounds read. Adjacent stack bytes may influence segment state or LED output, and a fault is possible. Incoming notifications do not trigger an automatic UDP rebroadcast, so a practical information leak has not been demonstrated. There is no out-of-bounds write shown here. The included ASan reproducer is standalone, not a hardware test.
To Reproduce Bug
- Enable receive segment bounds and segment options, enable UDP sync, and keep the node outside realtime mode. Wait at least one second after WLED sends its own notification.
- Send a 42-byte notifier packet to
udpPortfrom the LAN: byte 0 = 0, byte 1 = 0, byte 11 = 12, byte 36 matchesreceiveGroups, byte 39 = 1 segment, byte 40 = 36, and byte 41 = segment ID 0. - The check accepts offset 41, then the parser reads segment fields beyond the received bytes. This path is confirmed from source; device behavior has not been tested.
Expected Behavior
WLED should ignore incomplete segment data. Pass the actual received length to parseNotifyPacket() and check ofs + 36 <= length before reading a segment; the ESP-NOW caller also needs to pass its assembled length.
Install Method
Binary from WLED.me
What version of WLED?
Which microcontroller/board are you seeing the problem on?
ESP8266
Relevant log/trace output
Anything else?
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
DedeHai commentedon Oct 31, 2026
@coderabbitai is this an issue with internally generated packets? when can this issue arise?
coderabbitai commentedon Oct 31, 2026
Analysis chain
Script executed:
#!/bin/bash gh issue view 5942 --repo wled/WLED --json title,body,comments,urlLength of output: 3322
Script executed:
Length of output: 5104
Script executed:
Length of output: 22771
@DedeHaiNormal WLED-generated UDP sync packets should not trigger this issue. Inwled00/udp.cpp,notify()writes a complete 36-byte record for each advertised active segment. It sends the fullWLEDPACKETSIZEbuffer. The receiver also ignores its own broadcasts on the primary notifier port.The reported issue arises when a received packet advertises segment data that it does not contain. For example:
For the segment-read case, the receiver must accept the sync group, have
receiveSegmentOptionsorreceiveSegmentBoundsenabled, and be outside realtime mode. The one-second suppression period after sending its own notification must also have expired.A concrete example is a 42-byte packet that declares version 12, one segment, and a 36-byte segment stride. The segment starts at offset 41. The check accepts it because
41 + 36 <= 1472, although the received packet does not contain that segment record. The parser can then read beyond the 43-byte stack buffer.Ordinary UDP packet loss does not cause this. A lost datagram or an incomplete IP fragment set does not normally arrive as a shorter UDP datagram.
ESP-NOW also calls the parser without a length, but its buffer and assembly path differ. That path needs separate validation; it is not evidence that normal WLED-generated traffic triggers this specific stack-buffer read.
This is a malformed-input handling issue, not a demonstrated failure during normal WLED-to-WLED UDP sync. The source confirms the invalid read path; a device crash has not been verified.
Learnings used
You are interacting with an AI system.
softhack007 commentedon Oct 31, 2026
I think this is only a problem with rogue/fabricated packages. We should actually decide if we want to go all the way and harden WLED against fabricated packages in all places - including DMX messages, node list, udp sync, json api, http api, esp-now, etc.
Even when we fix all these potential buffer overread scenarios, the next threat is fabricated content, even with correct packet sizes.
In this special case,
parseNotifyPacket()handles 12 versions of the sync format, and to really make it bullet-proof the function needs the received packet size as parameter, and compare against the size before each processing step.I've already added a safeguard for minimal packet size 12 in #5932 (comment).
softhack007 commentedon Oct 31, 2026
@K-ANOY do you have a POC realistic exploit based on the buffer overread you found? If yes, what are the exploit consequences related to traditional security areas of concern: confidentiality, integrity, availability, and accountability?
softhack007 commentedon Oct 31, 2026
@K-ANOY as a side note: please make sure to declare AI support when posting bug reports. Your description has certain phrases and technical details that smell like AI - especially "the included ASan reproducer is standalone" (so where is it?).
avoid buffer overreading in parseNotifyPacket()