Closed code423n4 closed 2 years ago
Tomio
because if there's no check address(this).balance != 0 then doesnt need to call transfer, can save gas
address(this).balance
https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/managers/Manager.sol#L51
Remix
Example: If transfer first:
function sendETH(address _receive) external payable { (bool success, ) = _receive.call{value: address(this).balance}(''); if(success == false) require(false, "Transfer ETH Failed"); } // 22276 gas
If check address(this).balance first
function correctSendEth(address _receive) external payable { uint eth_balance = address(this).balance; if (eth_balance != 0){ (bool success, ) = _receive.call{value: eth_balance}(''); if(success == false) require(false, "Transfer ETH Failed"); } } //21923 gas
Dup #211
Handle
Tomio
Vulnerability details
Impact
because if there's no check
address(this).balance
!= 0 then doesnt need to call transfer, can save gasProof of Concept
https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/managers/Manager.sol#L51
Tools Used
Remix
Recommended Mitigation Steps
Example: If transfer first:
If check
address(this).balance
first