The withdrawInheritedFunds function is vulnerable to reentrancy attacks because it performs state-dependent logic after transferring funds. A malicious beneficiary can exploit this by re-entering the function during an Ether or ERC-20 token transfer, causing an unexpected flow of execution and potentially draining the contract.
• The function loops over beneficiaries and sends them either Ether (call{value: amountPerBeneficiary}("")) or ERC-20 tokens (safeTransfer).
• If a beneficiary is a malicious contract, its fallback function can re-enter withdrawInheritedFunds before the loop completes.
Loss of all funds in the contract, as a single malicious beneficiary can recursively withdraw multiple times before others get their share.
Unfair distribution, where a single attacker gets more than their fair share of the inheritance.
Manual review
Use Reentrancy Guards
Add OpenZeppelin’s nonReentrant modifier to prevent recursive calls:
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.