The inherit
function is callable by any user once the inactivity deadline passes. It does not verify that the caller is an authorized beneficiary. Specifically, if there is exactly one beneficiary in the array, the function assigns ownership to msg.sender
without verifying if the caller is indeed that sole beneficiary. This flaw can allow an attacker to take control of the contract by triggering the inheritance process improperly.
(See around line 94)
Root Cause:
The root cause is the lack of access control and proper validation within the inherit
function. There is no check to ensure that the caller is a designated beneficiary before changing the owner or marking the contract as inherited.
Impact:
If the contract has a single beneficiary, an attacker can exploit this flaw by calling the inherit
function after the deadline expires. The attacker would then be set as the new owner, potentially gaining control of all funds and assets managed by the contract. In a multi-beneficiary scenario, while the impact is less direct (setting isInherited
to true), it may still lead to unintended behavior in downstream operations.
Recommendation:
Access Control: Introduce strict access control to ensure that only the authorized beneficiary (or beneficiaries) can call the inherit
function.
Caller Verification: Add a condition to verify that msg.sender
is included in the list of beneficiaries before allowing any ownership changes.
Review Inheritance Logic: Consider reviewing the logic for the "sole beneficiary" clause. Ensure that even with one beneficiary, the transfer of ownership happens only after proper authentication and confirmation from the beneficiary.
Proof of Concept:
Setup:
Deploy the contract with a single beneficiary added via the addBeneficiery
function.
Wait until the inactivity deadline passes.
Attack:
An attacker (not the designated beneficiary) calls the inherit
function.
The function checks block.timestamp
against the deadline, which passes.
Since beneficiaries.length
equals 1, the contract sets owner = msg.sender
, making the attacker the new owner.
The attacker now controls the contract and can execute owner-restricted functions.
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.