From cf71f5767dad92f8c9bbe551b83e4f6d6b9cd08b Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sat, 26 May 2018 21:02:23 +0300 Subject: [PATCH] Fix potential DoS vector for masternode payments (#2071) * Skip only already verified mn payments vote duplicates * Update mn payment vote stats only if mn payment vote sig is ok --- src/masternode-payments.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index b7229b7f3..7dca88114 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -351,8 +351,8 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, const std::string& strCom auto res = mapMasternodePaymentVotes.emplace(nHash, vote); - // Avoid processing same vote multiple times - if(!res.second) { + // Avoid processing same vote multiple times if it was already verified earlier + if(!res.second && res.first->second.IsVerified()) { LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- hash=%s, nBlockHeight=%d/%d seen\n", nHash.ToString(), vote.nBlockHeight, nCachedBlockHeight); return; @@ -375,11 +375,6 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, const std::string& strCom return; } - if(!UpdateLastVote(vote)) { - LogPrintf("MASTERNODEPAYMENTVOTE -- masternode already voted, masternode=%s\n", vote.masternodeOutpoint.ToStringShort()); - return; - } - masternode_info_t mnInfo; if(!mnodeman.GetMasternodeInfo(vote.masternodeOutpoint, mnInfo)) { // mn was not found, so we can't check vote, some info is probably missing @@ -407,6 +402,11 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, const std::string& strCom return; } + if(!UpdateLastVote(vote)) { + LogPrintf("MASTERNODEPAYMENTVOTE -- masternode already voted, masternode=%s\n", vote.masternodeOutpoint.ToStringShort()); + return; + } + CTxDestination address1; ExtractDestination(vote.payee, address1); CBitcoinAddress address2(address1);