A critical reentrancy vulnerability has been identified in the InheritanceManager contract's sendERC20 function. This vulnerability allows an attacker to drain all ERC20 tokens from the contract through a reentrancy attack. Additionally, the attacker can take ownership of the contract due to improper state management.
The vulnerability exists due to three main issues:
ERC20 Reentrancy Attack Vector:
State changes (deadline update) occur after the token transfer
Improperly implemented reentrancy guard
Malicious ERC20 tokens can execute code in their transfer function
Ownership Manipulation:
Attacker can gain ownership of the contract
Combined with the ERC20 drain vulnerability, this gives complete control to the attacker
Contract Interactions Vulnerability:
As noted in the test comments, similar reentrancy issues could affect the contractInteractions function
The test demonstrates this by:
Creating a malicious ERC20 token (BadToken) with a reentrancy hook in its transfer function
Setting up the contract with 100 tokens
Creating an attacker contract (BadGuyErc20Contract)
Waiting for the inheritance period (90 days)
Executing the attack which:
Takes ownership of the contract
Drains all tokens through reentrancy
Code snippet showing the attack mechanism:
Critical severity. The vulnerability allows:
Complete drainage of contract's ERC20 token balances
Unauthorized takeover of contract ownership
Compromise of the entire inheritance management system
Potential exploitation through any ERC20 token interactions
Manual code review
Foundry test framework
Custom test cases with malicious ERC20 token implementation
Implement the Checks-Effects-Interactions pattern:
Move all state changes before token transfers
Update deadline before safeTransfer calls
Add proper reentrancy protection:
Implement OpenZeppelin's ReentrancyGuard
Add nonReentrant modifier to all external functions that interact with tokens
Use correct reentrancy guard keys as mentioned in test comments
Example fix structure:
or
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.