Add spoof detection for UDP packets in UdpMulticastHandler (#9905)

* Add spoof detection for UDP packets in UdpMulticastHandler

* Implement isFromUs function for packet origin validation

* ampersand
This commit is contained in:
Tom
2026-03-14 19:34:19 -05:00
committed by GitHub
co-authored by GitHub
parent 3fcbfe4370
commit 4890f7084f
+6 -1
View File
@@ -73,6 +73,11 @@ class UdpMulticastHandler final
LOG_DEBUG("Decoding MeshPacket from UDP len=%u", packetLength);
bool isPacketDecoded = pb_decode_from_bytes(packet.data(), packetLength, &meshtastic_MeshPacket_msg, &mp);
if (isPacketDecoded && router && mp.which_payload_variant == meshtastic_MeshPacket_encrypted_tag) {
// Drop packets with spoofed local origin — no legitimate LAN node should send from=0 or our own nodeNum
if (isFromUs(&mp)) {
LOG_WARN("UDP packet with spoofed local from=0x%x, dropping", mp.from);
return;
}
mp.transport_mechanism = meshtastic_MeshPacket_TransportMechanism_TRANSPORT_MULTICAST_UDP;
mp.pki_encrypted = false;
mp.public_key.size = 0;
@@ -113,4 +118,4 @@ class UdpMulticastHandler final
AsyncUDP udp;
bool isRunning;
};
#endif // HAS_UDP_MULTICAST
#endif // HAS_UDP_MULTICAST