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

Possible Reentrancy In InheritanceManager::withdrawInheritedFunds Leading To Drainage Of Contract Funds

Summary: InheritanceManager::withdrawInheritedFunds lacks the nonreentrant modifier, potentially draining funds from the contract before all beneficiaries are paid.

Vulnerability Details: InheritanceManager::withdrawInheritedFunds lacks the nonReentrant modifier, potentially draining funds from the contract before all beneficiaries are paid.

//@audit --> Possible reentrancy can lead to contract being drained, no nonreentrant modifier
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: A malicious beneficiary could re-enter and withdraw more than their share, leaving others unpaid.

Tools Used: Foundry

Recommendations: Use of nonreentrant modifier on InheritanceManager::withdrawInheritedFunds

//@audit --> Possible reentrancy can lead to contract being drained, no nonreentrant modifier
function withdrawInheritedFunds(address _asset) external nonReentrant {
if (!isInherited) {
revert NotYetInherited();
}
Updates

Lead Judging Commences

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

Support

FAQs

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