InheritanceManager::beneficiaries
is an array of addresses. The function removeBeneficiary()
resets the first instance of the address-to-remove to address(0). The array length remains the same. Some functions in InheritanceManager
use the array's length as the number of addresses that the funds have to be split between and they do not account for deletions. Functions affected by this include withdrawInheritedFunds()
, buyOutEstateNFT()
and inherit()
. The impact on each of these functions is demonstrated in the Proof Of Concept section. Using call() while iterating over the beneficiaries
array leads to transfers to address(0), i.e., burnt ETH, for deleted array items. This call happens in the following line in withdrawInheritedFunds():
Token transfers revert when asked to send tokens to address(0). This causes DOS of the buyOutEstateNFT()
function as this does not allow ETH transfers and token transfers will always revert if there is a deletion in the array.
Portion of ETH which should be sent to beneficiaries of the contract is burnt instead.
DOS in token transfers executed by iterating over the array. (withdrawInheritedFunds(tokenAddr)
, and buyOutEstateNFT()
)
inherit()
logic broken.
Manual Code Review, Foundry
Copy the following into the project test folder and run the tests.
Expected output:
Before each transfer, you can check for zero addresses to prevent call() sending ether to address(0) or token transfers reverting.
You can use a mapping (address => bool) instead of an array to store the beneficiary addresses, and a counter to keep track of total addresses added/removed. This removes the problem of holes in an array from item deletion, and also improves calculations based on number of addresses. Additionally this prevents duplicate entries in beneficiaries
.
Instead of iterating over the addresses to send them the assets, you can implement a withdraw function that can be called by the beneficiaries. This function would check msg.sender
against the mapping implemented and transfer the allocated funds to the calling address.
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.