mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-20 20:21:22 +00:00
Don't update the NodeDB if the nodeinfo has a mismatching public key (#7652)
This commit is contained in:
parent
d538ad170c
commit
e5e8683cdb
@ -1631,9 +1631,11 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
|
|||||||
printBytes("Incoming Pubkey: ", p.public_key.bytes, 32);
|
printBytes("Incoming Pubkey: ", p.public_key.bytes, 32);
|
||||||
|
|
||||||
// Alert the user if a remote node is advertising public key that matches our own
|
// Alert the user if a remote node is advertising public key that matches our own
|
||||||
if (owner.public_key.size == 32 && memcmp(p.public_key.bytes, owner.public_key.bytes, 32) == 0 && !duplicateWarned) {
|
if (owner.public_key.size == 32 && memcmp(p.public_key.bytes, owner.public_key.bytes, 32) == 0) {
|
||||||
|
if (!duplicateWarned) {
|
||||||
duplicateWarned = true;
|
duplicateWarned = true;
|
||||||
char warning[] = "Remote device %s has advertised your public key. This may indicate a compromised key. You may need "
|
char warning[] =
|
||||||
|
"Remote device %s has advertised your public key. This may indicate a compromised key. You may need "
|
||||||
"to regenerate your public keys.";
|
"to regenerate your public keys.";
|
||||||
LOG_WARN(warning, p.long_name);
|
LOG_WARN(warning, p.long_name);
|
||||||
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
||||||
@ -1642,13 +1644,20 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
|
|||||||
sprintf(cn->message, warning, p.long_name);
|
sprintf(cn->message, warning, p.long_name);
|
||||||
service->sendClientNotification(cn);
|
service->sendClientNotification(cn);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (info->user.public_key.size == 32) { // if we have a key for this user already, don't overwrite with a new one
|
||||||
|
// if the key doesn't match, don't update nodeDB at all.
|
||||||
|
if (p.public_key.size != 32 || (memcmp(p.public_key.bytes, info->user.public_key.bytes, 32) != 0)) {
|
||||||
|
LOG_WARN("Public Key mismatch, dropping NodeInfo");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (info->user.public_key.size > 0) { // if we have a key for this user already, don't overwrite with a new one
|
|
||||||
LOG_INFO("Public Key set for node, not updating!");
|
LOG_INFO("Public Key set for node, not updating!");
|
||||||
// we copy the key into the incoming packet, to prevent overwrite
|
// we copy the key into the incoming packet, to prevent overwrite
|
||||||
p.public_key.size = 32;
|
p.public_key.size = 32;
|
||||||
memcpy(p.public_key.bytes, info->user.public_key.bytes, 32);
|
memcpy(p.public_key.bytes, info->user.public_key.bytes, 32);
|
||||||
} else if (p.public_key.size > 0) {
|
} else if (p.public_key.size == 32) {
|
||||||
LOG_INFO("Update Node Pubkey!");
|
LOG_INFO("Update Node Pubkey!");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user