The withdrawInheritedFunds
function in the InheritanceManager contract lacks reentrancy protection despite making multiple external calls that could be exploited by malicious contracts. This oversight contradicts the security pattern applied to other functions in the contract and could potentially lead to fund drainage.
The function makes external calls to transfer ETH and ERC20 tokens without the nonReentrant
modifier that is consistently applied to other sensitive functions in the contract:
This function is particularly vulnerable to reentrancy attacks because:
It uses low-level call
to transfer ETH, which can trigger arbitrary code execution in the recipient
It makes multiple transfers in a loop, which could be exploited if one of the beneficiaries is a malicious contract
It calculates the distribution amount once at the beginning based on the current balance
No state is updated between transfers to prevent repeated withdrawals
If one of the beneficiaries is a malicious contract, it could exploit this vulnerability to:
Reenter the withdrawInheritedFunds
function before the first call completes
Drain additional funds beyond their fair share
Disrupt the inheritance distribution process
The severity is high because:
It directly affects the core fund distribution mechanism
It could lead to loss of funds beyond intended amounts
It contradicts the security pattern applied to other functions in the contract
Manual code review
Add the nonReentrant
modifier (make sure to first fix the issue in that modifier as reported) to the function to prevent reentrancy attacks:
For additional security, consider also implementing a pull pattern as suggested in the beneficiary withdrawal distribution issue, which would inherently provide better protection against reentrancy by allowing each beneficiary to withdraw their funds independently.
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.