Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Lacks Fallback and Receive Functions, Preventing ETH Payments

Summary

The InheritanceManager.sol smart contract is currently unable to receive ETH payments. For a contract to accept ETH, it must implement the receive or fallback function. As InheritanceManager.sol is intended to function like a wallet, it is essential for it to support ETH transactions, which is a core feature of any wallet

Vulnerability Details

The following test which can be added to InheritanceManagerTest.t.sol demonstrates the issue.

function test_cannot_acceptEth_transfer()public {
// Allocating 10 ether to this contract
vm.deal(address(this), 10 ether);
// Attempting to transfer 1 ether to the InheritanceManager contract
(bool success, ) = payable(address(im)).call{value: 1 ether}("");
// Verifying that the transfer failed
vm.assertEq(success, false);
// Checking that the InheritanceManager contract's balance remains 0
uint256 inheritanceManagerBalance = address(im).balance;
vm.assertEq(inheritanceManagerBalance, 0);
}

Impact

This bug would impact the ability for the smart contract to receive ether payment which is crucial for it to work like a backup wallet

Tools Used

Foundry test

Recommendations

To resolve this issue, add the receive and fallback functions to InheritanceManager.sol as shown below:

function fallback()external payable{
}
function receive() external payable{
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 9 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Missing receive() or fallback() function

Support

FAQs

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

Give us feedback!