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

Security Vulnerabilities 2

Summary

Logical & Functional Issues

Vulnerability Details

Incorrect Beneficiary Removal Logic

Impact

The function removeBeneficiary() deletes an entry from the array but does not shift remaining elements. This leaves a gap and can cause unexpected behavior.

Tools Used

/**
* @dev removes entries from beneficiaries in case inheritance gets revoked or
* an address needs to be replaced (lost keys e.g.)
* @param _beneficiary address to be removed from the array beneficiaries
*/
function removeBeneficiary(address _beneficiary) external onlyOwner {
uint256 indexToRemove = _getBeneficiaryIndex(_beneficiary);
delete beneficiaries[indexToRemove];
}

Recommendations

Fix removeBeneficiary() to shift array elements properly

function removeBeneficiary(address _beneficiary) external onlyOwner {
uint256 indexToRemove = _getBeneficiaryIndex(_beneficiary);
require(indexToRemove < beneficiaries.length, "Invalid beneficiary");
// Move the last element into the removed slot
beneficiaries[indexToRemove] = beneficiaries[beneficiaries.length - 1];
beneficiaries.pop();
}
Updates

Lead Judging Commences

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

Incorrect removal from beneficiary list causes funds to be send to 0 address

Support

FAQs

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