Skip to content

Commit 185630c

Browse files
committed
fix: address packet auth static analysis
Make the routing authentication gate input const and collapse licensed Admin authorization into a single branch so legacy response, local, channel, and PKI checks run only for non-licensed-remote traffic.
1 parent 5090c81 commit 185630c

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/mesh/FloodingRouter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bool FloodingRouter::perhapsHandleUpgradedPacket(const meshtastic_MeshPacket *p)
7171
// Verify the replacement before deleting the valid lower-hop copy waiting in the TX queue.
7272
// This is intentionally redundant with ReliableRouter's ingress gate: it keeps this helper
7373
// safe if another caller is introduced later.
74-
if (passesRoutingAuthGate(const_cast<meshtastic_MeshPacket *>(p)) != RoutingAuthVerdict::ACCEPT)
74+
if (passesRoutingAuthGate(p) != RoutingAuthVerdict::ACCEPT)
7575
return true;
7676

7777
// If we overhear a duplicate copy of the packet with more hops left than the one we are waiting to

src/mesh/Router.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ bool checkXeddsaReceivePolicy(meshtastic_MeshPacket *p)
688688
}
689689
#endif
690690

691-
RoutingAuthVerdict passesRoutingAuthGate(meshtastic_MeshPacket *p)
691+
RoutingAuthVerdict passesRoutingAuthGate(const meshtastic_MeshPacket *p)
692692
{
693693
// Routing still needs the original encrypted representation for byte-for-byte relay and for
694694
// MQTT uplink. Authenticate a copy here; handleReceived() performs the normal in-place decode

src/mesh/Router.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ enum class RoutingAuthVerdict { ACCEPT, OPAQUE_RELAY_ONLY, REJECT };
175175
DecodeState perhapsDecode(meshtastic_MeshPacket *p);
176176

177177
/** Apply receive authentication before routing state mutation; unknown-channel packets may remain opaque relay-only. */
178-
RoutingAuthVerdict passesRoutingAuthGate(meshtastic_MeshPacket *p);
178+
RoutingAuthVerdict passesRoutingAuthGate(const meshtastic_MeshPacket *p);
179179
#ifdef PIO_UNIT_TESTING
180180
uint32_t routingAuthEvaluationCount();
181181
void resetRoutingAuthEvaluationCount();

src/modules/AdminModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
146146
meshtastic_Channel *ch = &channels.getByIndex(mp.channel);
147147
const bool licensedRemote = owner.is_licensed && mp.from != 0;
148148
bool authorizedLicensedSigner = false;
149+
// Could tighten responses further by tracking the last public key queried.
149150
if (licensedRemote) {
150151
const bool directedAdmin = mp.to == nodeDB->getNodeNum() && !isBroadcast(mp.to) &&
151152
mp.decoded.portnum == meshtastic_PortNum_ADMIN_APP && !mp.pki_encrypted;
@@ -165,7 +166,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
165166
myReply = allocErrorResponse(meshtastic_Routing_Error_ADMIN_PUBLIC_KEY_UNAUTHORIZED, &mp);
166167
return handled;
167168
}
168-
LOG_INFO("Signed licensed admin payload with authorized Router-verified sender");
169+
LOG_INFO("Signed licensed admin payload with Router-verified sender");
169170
}
170171
if (messageIsResponse(r)) {
171172
// Only accept a response from a remote we sent the matching request to. from == 0 is a

0 commit comments

Comments
 (0)