diff --git a/src/avalanche/processor.cpp b/src/avalanche/processor.cpp --- a/src/avalanche/processor.cpp +++ b/src/avalanche/processor.cpp @@ -216,10 +216,15 @@ peerData = std::make_unique(); { - // The proof. - CDataStream stream(ParseHex(argsman.GetArg("-avaproof", "")), - SER_NETWORK, 0); - stream >> peerData->proof; + try { + CDataStream stream(ParseHex(argsman.GetArg("-avaproof", "")), + SER_NETWORK, 0); + stream >> peerData->proof; + } catch (const std::exception &e) { + LogPrintf("%s\n", e.what()); + error = _("the supplied avalanche proof has invalid format"); + return nullptr; + } } ProofValidationState proof_state; @@ -249,6 +254,11 @@ } } + if (masterKey.GetPubKey() != peerData->proof.getMaster()) { + error = _("the master key does not match the proof public key"); + return nullptr; + } + // Generate the delegation to the session key. DelegationBuilder dgb(peerData->proof); if (sessionKey.GetPubKey() != peerData->proof.getMaster()) { diff --git a/test/functional/abc_rpc_avalancheproof.py b/test/functional/abc_rpc_avalancheproof.py --- a/test/functional/abc_rpc_avalancheproof.py +++ b/test/functional/abc_rpc_avalancheproof.py @@ -226,6 +226,14 @@ expected_msg="Error: the avalanche master key is invalid", ) + node.assert_start_raises_init_error( + self.extra_args[0] + [ + "-avaproof={}".format(proof), + "-avamasterkey=cN55daf1HotwBAgAKWVgDcoppmUNDtQSfb7XLutTLeAgVc3u8hik", + ], + expected_msg="Error: the master key does not match the proof public key", + ) + def check_proof_init_error(proof, message): node.assert_start_raises_init_error( self.extra_args[0] + [ @@ -235,6 +243,8 @@ expected_msg="Error: " + message, ) + check_proof_init_error("This is not a serialized proof", + "the supplied avalanche proof has invalid format") check_proof_init_error(no_stake, "the avalanche proof has no stake") check_proof_init_error(dust,