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

[L-1] Anyone can call `InheritanceManager::withdrawInheritedFunds` causing an unexpected dispersal of funds to beneficiaries

Description: In InheritanceManager::withdrawInheritedFunds, there are no access controls to prevent non-beneficiaries from causing a withdrawal of funds to beneficiaries. This lack of access control allows unauthorized users to trigger fund dispersals.

Impact: This vulnerability disrupts the protocol by allowing anyone to withdraw funds on behalf of beneficiaries, thereby stripping beneficiaries of control over when funds are withdrawn. This can be exploited by malicious actors to create unexpected and unauthorized fund transfers.

Recommended Mitigation: Implement a modifier that provides the access check to ensure that only beneficiaries can call InheritanceManager::withdrawInheritedFunds.

Add the following modifier to InheritanceManager contract in InheritanceManager.sol:

+ modifier onlyBeneficiary() {
+ bool isBeneficiary = false;
+ for (uint256 i = 0; i < beneficiaries.length; i++) {
+ if (beneficiaries[i] == msg.sender) {
+ isBeneficiary = true;
+ break;
+ }
+ }
+ require(isBeneficiary, "Only beneficiaries can call this function");
+ _;
+ }

Add the modifier to InheritanceManager::withdrawInheritedFunds:

- function withdrawInheritedFunds(address _asset) external {
+ function withdrawInheritedFunds(address _asset) external onlyBeneficiary {
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);
}
}
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 9 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.

Give us feedback!