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
This commit is contained in:
UdjinM6 2018-05-26 21:02:23 +03:00 committed by GitHub
parent ef85d5144d
commit cf71f5767d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);