The ::inherit()
function serves two purposes (per the README
);
Enable an owner who lost their keys to reclaim inheritance from beneficiaries slot0
Enable claimers to claim funds after 90 days deadline
but there is a flaw in the logic of this function that can be manipulated by an attacker to steal all the inheritance.
The below lines in ::inherit()
stipulates that if the beneficiary for the inheritance is just one person, then whoever called the function (i.e. the msg.sender
) should automatically become the owner
of the inheritance.
However this check fails to account for the fact that the msg.sender
could be a non-beneficiary of the inheritance.
A non-beneficiary can call ::inherit() for an inheritance that has only one beneficiary, become the owner
, and then send the inheritance to themselves by calling either of the ::sendETH()
or ::sendERC20()
functions.
Manual Review
Foundry
Imagine this scenario:
A father sets up an inheritance of 100 ETH
and adds his only son as the sole beneficiary
His jealous brother is aware of the logic flaw in the contract and monitors the inheritance to know when the deadline is up
Once the deadline is up, the uncle calls the ::inherit()
function and automatically becomes the owner of the inheritance
He quickly calls the ::sendETH()
function and sends the inheritance to himself
The father and son are unaware that the inheritance has been stolen, and even they are aware they cannot do anything as calling the ::inherit()
function resets the deadline
to 90 days
Add the following test to the InheritanceManagerTest
contract:
Since the ::inherit()
function is meant to be called by only one of two parties;
the owner
of the inheritance, i.e., whoever set up the inheritance, or
the beneficiary(s),
add a check that ensures that whoever calls this function is one of either parties
This way, the ::inherit()
function is restricted from non-beneficiaries.
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.