Description: In InheritanceManager::removeBeneficiary
using the 'delete' keyword sets the element to the zero address rather than removing it from the array. This leaves a "hole" in the array.
Impact: This bug interferes with subsequent logic in functions like InheritanceManager::buyOutEstateNFT
and InheritanceManager::withdrawInheritedFunds
, potentially causing incorrect calculations and distribution errors. For instance, the zero address may be inadvertently included in the beneficiary count, resulting in misallocated funds.
Proof of Concept: Include the following tests in the InheritanceManagerTest.t.sol
file:
Recommended Mitigation: Swap the element to remove with the last element and then use the pop operation to remove it from the array. This approach is gas efficient and avoids leaving a zero address in the array.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.