Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Unrestricted Inheritance Trigger Leading to Unauthorized Ownership Change

Summary

Vulnerability Details

ImpactDetails:

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:

  1. Setup:

    • Deploy the contract with a single beneficiary added via the addBeneficiery function.

    • Wait until the inactivity deadline passes.

  2. 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.


Updates

Lead Judging Commences

0xtimefliez Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Inherit depends on msg.sender so anyone can claim the contract

0xtimefliez Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Inherit depends on msg.sender so anyone can claim the contract

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.