Skip to content

Fuzzer 01 - Dispatcher, Packet: always check if we have enough 'len' before pulling bytes out of the raw frame - #3267

Open
h0lad wants to merge 2 commits into
meshcore-dev:devfrom
h0lad:had/harden_length_matching
Open

Fuzzer 01 - Dispatcher, Packet: always check if we have enough 'len' before pulling bytes out of the raw frame#3267
h0lad wants to merge 2 commits into
meshcore-dev:devfrom
h0lad:had/harden_length_matching

Conversation

@h0lad

@h0lad h0lad commented Aug 21, 2026

Copy link
Copy Markdown

I started playing around with a fuzzer. This is the first result.

@h0lad
h0lad force-pushed the had/harden_length_matching branch 3 times, most recently from fe8b5ce to b7e9fe9 Compare August 21, 2026 18:46
@h0lad
h0lad marked this pull request as ready for review August 21, 2026 18:48
@h0lad
h0lad force-pushed the had/harden_length_matching branch from b7e9fe9 to a6a402f Compare August 21, 2026 18:53
Holger Adams added 2 commits August 21, 2026 20:53
Every received frame is first turned into a 'Packet' struct by Dispatcher::tryParsePacket().

The frame is a length-prefixed byte string:
[header][transport_codes(optional)][path_length][path][payload]

The parser has to read the 'header' *first*, and only then does it know how many more bytes it is required to read.

The bug is that it never checks that those bytes actually arrived.
Packet::readFrom() is a second, independent parser for the same wire format:

[header][transport_codes(optional)][path_length][path][payload]

It is used by the ESP-NOW bridge (src/helpers/bridges/ESPNowBridge.cpp) to turn a received blob back into a 'Packet'.

It duplicates the parsing logic of Dispatcher::tryParsePacket() and has the same length-check problems, plus one more: the `path` read is not bounds-checked either.
@h0lad
h0lad force-pushed the had/harden_length_matching branch from a6a402f to 05da523 Compare August 21, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant