Skip to content

Conversation

@weebl2000
Copy link
Contributor

Severity: Low

Summary

The ADVERT packet handler copies the public key (32 bytes), timestamp (4 bytes), and signature (64 bytes) from the payload before checking whether payload_len is large enough to contain them. With a short payload, the memcpy operations read uninitialized data from within the payload buffer array.

The reads stay within the 184-byte payload[] array so this is not a true out-of-bounds access, but the parsed values (pub_key, timestamp, signature) contain garbage. The bounds check at line 251 catches it before any side-effects occur (no routing, no signature verification passes with garbage), but the ordering is sloppy and could become a real bug if the buffer layout changes.

Fix

Move the bounds check before any parsing. Undersized adverts are now rejected immediately with a debug log, before any memcpy operations execute.

Test plan

  • Normal advertisement exchange still works
  • Short/corrupt adverts are rejected with debug message
  • Build tested on Heltec_v3_companion_radio_ble

The ADVERT handler copied pub_key, timestamp, and signature from the
payload before checking whether payload_len was large enough to contain
them. With a short payload, the memcpy operations read uninitialized
data from within the payload buffer.

Move the bounds check before any parsing so undersized adverts are
rejected immediately. The minimum required is PUB_KEY_SIZE + 4 +
SIGNATURE_SIZE (100 bytes).
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