Skip to content

Commit 79bb549

Browse files
UdjinM6codex
andcommitted
fix: Guard mnauth by local masternode service
Co-authored-by: OpenAI Codex <codex@openai.com>
1 parent d1eab6c commit 79bb549

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/evo/mnauth.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,21 @@
1919
void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternodeManager& mn_activeman)
2020
{
2121
CMNAuth mnauth;
22-
if (mn_activeman.GetProTxHash().IsNull()) {
22+
const uint256 pro_tx_hash{mn_activeman.GetProTxHash()};
23+
if (pro_tx_hash.IsNull()) {
2324
return;
2425
}
26+
if (peer.IsInboundConn()) {
27+
const CService expected_service{mn_activeman.GetService()};
28+
const CService connected_service{static_cast<const CService&>(peer.addrBind)};
29+
if (expected_service != connected_service) {
30+
LogPrint(BCLog::NET_NETCONN, /* Continued */
31+
"CMNAuth::%s -- Not sending MNAUTH on unexpected local service, expected=%s, connected=%s, "
32+
"peer=%d\n",
33+
__func__, expected_service.ToStringAddrPort(), connected_service.ToStringAddrPort(), peer.GetId());
34+
return;
35+
}
36+
}
2537

2638
const auto receivedMNAuthChallenge = peer.GetReceivedMNAuthChallenge();
2739
if (receivedMNAuthChallenge.IsNull()) {
@@ -39,7 +51,7 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternode
3951
}
4052
const uint256 signHash{::SerializeHash(std::make_tuple(mn_activeman.GetPubKey(), receivedMNAuthChallenge, peer.IsInboundConn(), nOurNodeVersion))};
4153

42-
mnauth.proRegTxHash = mn_activeman.GetProTxHash();
54+
mnauth.proRegTxHash = pro_tx_hash;
4355

4456
// all clients uses basic BLS
4557
mnauth.sig = mn_activeman.Sign(signHash, false);

0 commit comments

Comments
 (0)