1

Research Paper, Page-5(Strict Balance Equality)I have read that attacker can use Selfdestruct() and forcibly send ethers to the contracts. My questions are: If Selfdestruct is meant for owner of smart contract only, how can the attacker use Selfdestruct()? How greater than or less than preventing the attacker from misusing the Selfdestruct?

1 Answer 1

1

The research paper shows that it is possible to send Ethers to contract even if you rejected Ethers in the fallback function of your contract.

The attacker can execute selfdesctruct on some contract with the address of your contract. This will send ETHs to your contract without invoking the fallback function

Let's understand this with the help of a contract. In this, the victim contract gas implemented a fallback function to reject ethers, so the developer of Victim contract assumes no one can send ETH to his contract.

But I can write an Attack contract with a selfdestruct function, where I will pass the address of the victim contract. This will allow me to send Ethers to victim contract. The reason being in case of self destruct, fallback function is not executed.

pragma solidity 0.5.1;

contract Victim{
    function() external payable {
        revert();
    }

    function getEthBalance() public view returns (uint){
        return address(this).balance;
    }
}

contract Attack {


    function pay() public payable {

    }

    function getEthBalance() public view returns (uint){
        return address(this).balance;
    }

    function kill(address payable victim) public {
        selfdestruct(victim);
    }

}

How greater than or less than preventing the attacker from misusing the Selfdestruct?

This purely depends on business logic, it means you should never assume that no one can send ETHs to your contract.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.