Skip to content

Conversation

@weebl2000
Copy link
Contributor

@weebl2000 weebl2000 commented Feb 11, 2026

Severity: Critical

Summary

When a node receives a PATH packet from a known contact, it decrypts the payload and parses a path_len field to find the route data inside. The problem is that path_len comes from the decrypted data itself, and nothing checks whether it's actually valid before using it to walk through the buffer.

A compromised or malicious contact can send a PATH packet where path_len claims to be much larger than the actual payload. The parser blindly advances past the end of the decrypted buffer and reads whatever happens to be in memory after it — stack variables, other packet data, etc. Depending on what onPeerPathRecv does with the resulting garbage pointers, this could crash the node or leak memory contents back to the attacker in a response.

Who can exploit this: any peer in your contacts list (they need a shared key for the MAC/decryption to pass).

What it takes: a single crafted PATH packet over RF.

What users might see

Even without a deliberate attack, this can be triggered by corrupted packets that happen to decrypt successfully (unlikely but possible with the 2-byte MAC). In practice, affected nodes could experience:

  • Unexpected reboots or freezes — reading past the buffer can hit unmapped memory or corrupt the stack, causing a hard fault on ESP32/nRF52
  • Broken path discovery — the node processes a garbage path and tries to route through it, leading to messages that never arrive or peers that appear unreachable
  • Ghost routesonPeerPathRecv stores a nonsense path for a contact, so subsequent direct messages to that peer get sent into the void until the next successful path exchange overwrites it
  • Intermittent connectivity — if the node crashes and reboots, it loses all in-memory routing state and has to rediscover peers from scratch, causing periodic drops

Most of these would look like "flaky mesh" rather than a security issue, which is part of what makes it worth fixing.

Fix

One bounds check after reading path_len — verify the buffer actually has room for the claimed path plus the extra_type byte before touching any of it. If not, drop the packet silently, same as a failed decryption.

Test plan

  • Normal PATH packet exchange still works (discovery, direct path return)
  • No regressions in flood/direct routing
  • Build tested on Heltec_v3_companion_radio_ble

The path_len field inside the decrypted PATH payload was used to advance
the parse cursor without validating it against the actual decrypted data
length. A malicious peer sharing a key could craft a PATH packet with an
oversized path_len, causing out-of-bounds reads past the decrypted buffer
when accessing the extra_type byte and extra data pointer.

Add a bounds check after reading path_len to ensure the decrypted buffer
contains enough bytes for the claimed path plus the mandatory extra_type
byte before dereferencing.
@weebl2000 weebl2000 force-pushed the fix/path-payload-bounds-check branch from 19fe548 to 24c4e0b Compare February 11, 2026 02:20
Log path_len and len when the bounds check fails, making it easier to
diagnose malformed or corrupt packets during development.
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.

2 participants