The nonReentrant
modifier in the InheritanceManager
contract is intended to prevent reentrancy attacks by using transient storage. However, there is a critical mismatch between the storage slots used for locking and checking. The modifier checks for a lock at slot 1 (tload(1)
), but sets the lock at slot 0 (tstore(0, 1)
), making the reentrancy protection completely ineffective.
This implementation error means that functions with this modifier are vulnerable to reentrancy attacks, despite appearing to be protected.
Reentrancy vulnerability: Functions protected by this modifier (including sendERC20
, sendETH
, and contractInteractions
) are vulnerable to reentrancy attacks, potentially allowing attackers to drain funds from the contract.
The following code demonstrates that the nonReentrant
modifier does not prevent reentrancy as intended:
Place the test in the test folder and run it with the following command
The PoC confirms that both protected functions can be called in sequence, which should not be possible with a properly functioning reentrancy guard.
Fix the mismatch between the storage slots used in the nonReentrant modifier:
Alternatively, for better clarity and safety, consider using OpenZeppelin's ReentrancyGuard implementation which is well-tested and audited:
Consider a scenario where an attacker exploits this vulnerability:
The attacker creates a malicious contract with a fallback function that calls back into the InheritanceManager.sendETH()
function
The attacker calls sendETH()
with their malicious contract as the recipient
When the InheritanceManager
sends ETH to the attacker's contract, the fallback function executes
The fallback function calls back into sendETH()
, which should be prevented by the nonReentrant modifier but isn't
This cycle repeats until the contract is drained of ETH
In a real inheritance management system, this could result in one malicious beneficiary stealing all funds from the contract before other legitimate beneficiaries can claim their share, completely undermining the intended inheritance distribution process.
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.