Skip to content

Fix for preserving pki_encrypted and public_key when relaying UDP multicast packets to radio.#9916

Merged
thebentern merged 5 commits into
meshtastic:developfrom
niklaswall:develop
Mar 19, 2026
Merged

Fix for preserving pki_encrypted and public_key when relaying UDP multicast packets to radio.#9916
thebentern merged 5 commits into
meshtastic:developfrom
niklaswall:develop

Conversation

@niklaswall

Copy link
Copy Markdown
Contributor

Fix for preserving pki_encrypted and public_key when relaying UDP multicast packets to radio.

PKI DMs sent over UDP multicast had their pki_encrypted flag and public_key fields explicitly cleared before being forwarded to the LoRa radio. This caused the receiving node to treat the packet as a channel-encrypted message it couldn't decrypt, silently dropping it.

The MQTT ingress path correctly preserves these fields. The UDP multicast ingress path should behave the same way.

🤝 Attestations

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • Heltec (Lora32) V3
    • Heltec Wireless Tracker V2

…ticast packets to radio.

PKI DMs sent over UDP multicast had their pki_encrypted flag and public_key fields explicitly cleared before being forwarded to the LoRa radio. This caused the receiving node to treat the packet as a channel-encrypted message it couldn't decrypt, silently dropping it.

The MQTT ingress path correctly preserves these fields. The UDP multicast ingress path should behave the same way.
@CLAassistant

CLAassistant commented Mar 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

Copy link
Copy Markdown
Contributor

@niklaswall, Welcome to Meshtastic!

Thanks for opening your first pull request. We really appreciate it.

We discuss work as a team in discord, please join us in the #firmware channel.
There's a big backlog of patches at the moment. If you have time,
please help us with some code review and testing of other PRs!

Welcome to the team 😄

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes UDP multicast ingress so PKI direct messages forwarded from LAN to LoRa retain PKI metadata (pki_encrypted and public_key), matching the behavior of the MQTT ingress path and preventing silent drops on the receiving node.

Changes:

  • Stop forcibly clearing mp.pki_encrypted and mp.public_key when decoding and relaying UDP multicast packets.
  • Preserve PKI fields on UDP multicast ingress so PKI DMs are handled correctly by the router/decrypt path.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/mesh/udp/UdpMulticastHandler.h
niklaswall and others added 3 commits March 17, 2026 06:47
Zeroize MeshPacket before decoding to prevent data leakage.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@thebentern thebentern requested a review from jp-bennett March 18, 2026 13:47
@thebentern

Copy link
Copy Markdown
Contributor

@jp-bennett tagging you since this was added in a97df4b

@niklaswall

Copy link
Copy Markdown
Contributor Author

Yes, it would be interesting to know why it was added! The commit message "Sanity check incoming UDP" does not really make sense since we were basically just "dropping" parts of the MeshPacket related to PKI encryption (pki_encrypted and public_key).

My best guess is that you might sometimes end up with garbage in the MeshPacket since memory was not initialized before decoding the protobuf.

Initializing MeshPacket to meshtastic_MeshPacket_init_zero before decoding the received data should fix that potential issue.
meshtastic_MeshPacket mp = meshtastic_MeshPacket_init_zero;

@thebentern thebentern merged commit 644d0d4 into meshtastic:develop Mar 19, 2026
77 checks passed
thebentern added a commit that referenced this pull request Mar 19, 2026
…ticast packets to radio. (#9916)

* Fix for preserving pki_encrypted and public_key when relaying UDP multicast packets to radio.

PKI DMs sent over UDP multicast had their pki_encrypted flag and public_key fields explicitly cleared before being forwarded to the LoRa radio. This caused the receiving node to treat the packet as a channel-encrypted message it couldn't decrypt, silently dropping it.

The MQTT ingress path correctly preserves these fields. The UDP multicast ingress path should behave the same way.

* Zeroize MeshPacket before decoding

Zeroize MeshPacket before decoding to prevent data leakage.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
jeek pushed a commit to jeek/Meshtastic-Exploiteers-Hacker-Pager that referenced this pull request Jun 30, 2026
…ticast packets to radio. (meshtastic#9916)

* Fix for preserving pki_encrypted and public_key when relaying UDP multicast packets to radio.

PKI DMs sent over UDP multicast had their pki_encrypted flag and public_key fields explicitly cleared before being forwarded to the LoRa radio. This caused the receiving node to treat the packet as a channel-encrypted message it couldn't decrypt, silently dropping it.

The MQTT ingress path correctly preserves these fields. The UDP multicast ingress path should behave the same way.

* Zeroize MeshPacket before decoding

Zeroize MeshPacket before decoding to prevent data leakage.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs first-contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants