Skip to content

Commit 58fee80

Browse files
NomDeTomthebentern
authored andcommitted
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
1 parent 3673af4 commit 58fee80

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/mesh/udp/UdpMulticastHandler.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ class UdpMulticastHandler final
7373
LOG_DEBUG("Decoding MeshPacket from UDP len=%u", packetLength);
7474
bool isPacketDecoded = pb_decode_from_bytes(packet.data(), packetLength, &meshtastic_MeshPacket_msg, &mp);
7575
if (isPacketDecoded && router && mp.which_payload_variant == meshtastic_MeshPacket_encrypted_tag) {
76+
// Drop packets with spoofed local origin — no legitimate LAN node should send from=0 or our own nodeNum
77+
if (isFromUs(&mp)) {
78+
LOG_WARN("UDP packet with spoofed local from=0x%x, dropping", mp.from);
79+
return;
80+
}
7681
mp.transport_mechanism = meshtastic_MeshPacket_TransportMechanism_TRANSPORT_MULTICAST_UDP;
7782
mp.pki_encrypted = false;
7883
mp.public_key.size = 0;
@@ -113,4 +118,4 @@ class UdpMulticastHandler final
113118
AsyncUDP udp;
114119
bool isRunning;
115120
};
116-
#endif // HAS_UDP_MULTICAST
121+
#endif // HAS_UDP_MULTICAST

0 commit comments

Comments
 (0)