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

[H-2] Reentrancy in InheritanceManager::withdrawInheritedFunds

Summary

Due to reentrancy guard being absent malicious benificary contract and call InheritanceManager::withdrawInheritedFunds from their receive function and can drain the eth funds of other benefeciers.

Vulnerability Details

Affected function

function withdrawInheritedFunds(address _asset) external {
if (!isInherited) {
revert NotYetInherited();
}
uint256 divisor = beneficiaries.length;
if (_asset == address(0)) {
uint256 ethAmountAvailable = address(this).balance;
uint256 amountPerBeneficiary = ethAmountAvailable / divisor;
for (uint256 i = 0; i < divisor; i++) {
address payable beneficiary = payable(beneficiaries[i]);
(bool success,) = beneficiary.call{value: amountPerBeneficiary}("");
require(success, "something went wrong");
}
} else {
uint256 assetAmountAvailable = IERC20(_asset).balanceOf(address(this));
uint256 amountPerBeneficiary = assetAmountAvailable / divisor;
for (uint256 i = 0; i < divisor; i++) {
IERC20(_asset).safeTransfer(beneficiaries[i], amountPerBeneficiary);
}
}
}

Impact

High impact causes the benificiers to lose their funds.

Tools Used

foundry

Recommendations

Mitigation-

Add reenctrancy guard modifier to the function

function withdrawInheritedFunds(address _asset) external nonReentrant
Updates

Lead Judging Commences

0xtimefliez Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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