Skip to content

Commit 5e2f353

Browse files
committed
fix: verify sender pubkey matches target node in P2P broadcast messages
Cross-reference the sender's public key against the node at the target IP in verifyFluxBroadcast, ensuring node operators can only broadcast messages about their own IP address.
1 parent 1d4a333 commit 5e2f353

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

ZelBack/src/services/fluxCommunicationUtils.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,19 @@ async function verifyFluxBroadcast(broadcast) {
181181
}
182182

183183
// if we get a map, we have hit the default case and searched for pubkeys
184-
const found = target instanceof Map
185-
? true
186-
: Boolean(await networkStateService.getFluxnodeBySocketAddress(target));
187-
188-
if (!found) {
189-
log.warn(error);
190-
return false;
184+
if (target instanceof Map) {
185+
// default case: already verified pubkey exists in network
186+
} else {
187+
const node = await networkStateService.getFluxnodeBySocketAddress(target);
188+
if (!node) {
189+
log.warn(error);
190+
return false;
191+
}
192+
// verify the sender's pubKey matches the node at the target IP
193+
if (node.pubkey !== pubKey) {
194+
log.warn(`Sender pubkey ${pubKey} does not match node at ${target}`);
195+
return false;
196+
}
191197
}
192198

193199
const messageToVerify = version + message + timestamp;

0 commit comments

Comments
 (0)