Skip to content

Commit d427030

Browse files
committed
Use the authoritative key on the PKI decrypt path
Resolve the inbound sender key via copyPublicKeyAuthoritative (hot/warm) instead of the opportunistic copyPublicKey, so authenticated DM attribution (pki_encrypted, p->from) does not rest on the ephemeral TMM NodeInfo cache. Outbound encrypt-to keying and the key-verification pending-key path are unchanged.
1 parent 1872e5b commit d427030

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/mesh/Router.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,13 @@ DecodeState perhapsDecode(meshtastic_MeshPacket *p)
624624
meshtastic_NodeInfoLite *ourNode = nullptr;
625625
if (p->channel == 0 && isToUs(p) && p->to > 0 && !isBroadcast(p->to) && rawSize > MESHTASTIC_PKC_OVERHEAD &&
626626
(ourNode = nodeDB->getMeshNode(p->to)) != nullptr && ourNode->public_key.size > 0) {
627-
// Resolve the sender's public key only for actual PKI-decrypt candidates: prefer NodeDB
628-
// (hot store or warm tier), else a not-yet-committed key held during an in-progress
629-
// key-verification handshake. On a full NodeDB miss, copyPublicKey() falls through to a
630-
// linear scan of TrafficManagement's large NodeInfo cache, so it must not run for every
631-
// encrypted channel packet from an unknown sender - only for packets we might decrypt.
627+
// Resolve the sender's public key only for actual PKI-decrypt candidates. Use
628+
// copyPublicKeyAuthoritative (hot store or warm tier only), not the opportunistic
629+
// copyPublicKey: authenticated DM attribution (pki_encrypted, p->from) must rest on
630+
// authoritative keys, never on the ephemeral TOFU TrafficManagement NodeInfo cache. A
631+
// not-yet-committed key from an in-progress key-verification handshake is tried below.
632632
meshtastic_NodeInfoLite_public_key_t remotePublic = {0, {0}};
633-
bool haveRemoteKey = nodeDB->copyPublicKey(p->from, remotePublic);
633+
bool haveRemoteKey = nodeDB->copyPublicKeyAuthoritative(p->from, remotePublic);
634634
// A pending key is an unverified identity claim supplied by whoever opened the handshake, so it is
635635
// accepted only for the exchange itself (checked after decode). perhapsEncode applies the same rule.
636636
bool havePendingKey = false;

0 commit comments

Comments
 (0)