Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: medium
Invalid

Possible Transaction Failure Due to Missing Balance Check Before Transfer

Summary

The InheritanceManager::sendETH function does not verify the contract’s balance before transferring ETH. If the contract lacks sufficient funds, the transaction will fail, causing gas wastage.

Vulnerability Details

  • The function directly attempts to send ETH without ensuring the contract has enough balance.

  • If the contract’s balance is insufficient, the transaction will fail, leading to unnecessary gas consumption.

Impact

  • Gas wastage due to failed transactions.

  • Poor user experience as transactions may unexpectedly fail.

Tools Used

  • Foundry (Forge) for smart contract testing

Proof of Concept:

Test case demonstrating the issue in InheritanceManagerTest.t.sol

function test_sendETHInsufficientBalanceFail() public {
// Arrange
vm.deal(address(im), 0.5 ether); // Assign only 0.5 ETH to the contract
vm.startPrank(owner);
console.log("Contract Balance Before:", address(im).balance);
console.log("User1 Balance Before:", user1.balance);
// Act
vm.expectRevert("Transfer Failed");
im.sendETH(1 ether, user1);
// Assert
console.log("Contract Balance After:", address(im).balance);
console.log("User1 Balance After:", user1.balance);
assertEq(address(im).balance, 0.5 ether);
assertEq(user1.balance, 0 ether);
vm.stopPrank();
}

Recommendations

Modify the InheritanceManager::sendETH function to include a balance check before attempting to transfer ETH.

function sendETH(uint256 _amount, address _to) external nonReentrant onlyOwner {
+ if (address(this).balance < _amount) {
+ revert InsufficientBalance();
+ }
(bool success,) = _to.call{value: _amount}("");
require(success, "Transfer Failed");
_setDeadline();
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.