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

Missing `onlyBeneficiaryWithIsInherited` modifier in `InheritanceManager::withdrawInheritedFunds` leading to potential unauthorized asset withdrawal.

Summary

The withdrawInheritedFunds function in the InheritanceManager contract is missing the crucial onlyBeneficiaryWithIsInherited modifier. This allows anyone to call withdrawInheritedFunds after inheritance, regardless of whether they are a designated beneficiary, leading to potential unauthorized asset withdrawal.

Vulnerability Details

  • Explanation:

    1. The onlyBeneficiaryWithIsInherited modifier verifies that the caller is a designated beneficiary and that the isInherited flag is true.

    2. Without this modifier, any address can call withdrawInheritedFunds once isInherited is true.

    3. withdrawInheritedFunds divides the contract's assets (ETH or ERC20) among the beneficiaries.

    4. A malicious actor could exploit this by calling withdrawInheritedFunds, potentially withdrawing assets before the intended beneficiaries.

@> 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

  • Unauthorized Asset Withdrawal: Malicious actors can call withdrawInheritedFunds when users are not ready to accept funds or if there is an unresolved issues between beneficiaries.

Tools Used

  • Manual Code Review

Recommendations

  1. Implement onlyBeneficiaryWithIsInherited Modifier:

    • Apply the onlyBeneficiaryWithIsInherited modifier to the withdrawInheritedFunds function. This will limit function execution to legitimate beneficiaries who have claimed the inheritance.

- function withdrawInheritedFunds(address _asset) external {
+ function withdrawInheritedFunds(address _asset) external onlyBeneficiaryWithIsInherited{
if (!isInherited) {
Updates

Lead Judging Commences

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

Support

FAQs

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