While I was reading a guide on smart contract security (by consensys) I found this:
// INSECURE
contract Auction {
address currentLeader;
uint highestBid;
function bid() payable {
require(msg.value > highestBid);
require(currentLeader.send(highestBid)); // Refund the old leader, if it fails then revert
currentLeader = msg.sender;
highestBid = msg.value;
}
}
The vulnerability here (quoted from the guide):
When it tries to refund the old leader, it reverts if the refund fails. This means that a malicious bidder can become the leader while making sure that any refunds to their address will always fail. In this way, they can prevent anyone else from calling the bid() function, and stay the leader forever.
How can someone make all the incoming transactions(the refunds) to their address fail? In case of a contract I guess the answer is having a revert
inside the fallback
function. In the case of simple address how can someone do it? I am asking cause it really blew my mind since I have never heard of this before(cause it's kind of pointless i guess).
Cheers!