Skip to content

Commit

Permalink
patched hole allowing attacker to enter masternode list with valid input
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Duffield committed Oct 7, 2014
1 parent 6f8352c commit fe9fddb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/clientversion.h
Expand Up @@ -9,7 +9,7 @@
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 10
#define CLIENT_VERSION_REVISION 14
#define CLIENT_VERSION_BUILD 0
#define CLIENT_VERSION_BUILD 1

// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
Expand Down
17 changes: 17 additions & 0 deletions src/darksend.cpp
Expand Up @@ -1599,6 +1599,23 @@ int CDarkSendPool::GetDenominationsByAmount(int64 nAmount){
return GetDenominations(vout1);
}

bool CDarkSendSigner::IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey){
CScript payee2;
payee2.SetDestination(pubkey.GetID());

CTransaction txVin;
uint256 hash;
if(GetTransaction(vin.prevout.hash, txVin, hash, true)){
BOOST_FOREACH(CTxOut out, txVin.vout){
if(out.nValue == 1000*COIN){
if(out.scriptPubKey == payee2) return true;
}
}
}

return false;
}

bool CDarkSendSigner::SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey){
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(strSecret);
Expand Down
1 change: 1 addition & 0 deletions src/darksend.h
Expand Up @@ -221,6 +221,7 @@ class CDarksendQueue
class CDarkSendSigner
{
public:
bool IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey);
bool SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey);
bool SignMessage(std::string strMessage, std::string& errorMessage, std::vector<unsigned char>& vchSig, CKey key);
bool VerifyMessage(CPubKey pubkey, std::vector<unsigned char>& vchSig, std::string strMessage, std::string& errorMessage);
Expand Down
5 changes: 5 additions & 0 deletions src/main.cpp
Expand Up @@ -4216,6 +4216,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
return false;
}

if(!darkSendSigner.IsVinAssociatedWithPubkey(vin, pubkey)) {
LogPrintf("dsee - Got mismatched pubkey and vin\n");
return false;
}

std::string errorMessage = "";
if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){
LogPrintf("dsee - Got bad masternode address signature\n");
Expand Down

0 comments on commit fe9fddb

Please sign in to comment.