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

The InheritanceManager Contract Fails to Reset the Inactivity Timer in Critical Functions, Leading to Potential Premature Inheritance Claims

Summary

Several functions within the InheritanceManager contract, which should ideally reset the inactivity timer upon execution by the contract owner, lack calls to the _setDeadline() function. This omission creates inconsistencies in the contract's intended behavior regarding the inactivity period and could lead to unexpected or premature inheritance claims by beneficiaries.


Vulnerability Details

1. Overview

The contract relies on the deadline state variable to determine if the owner has been inactive for a period (defined by TIMELOCK). Every owner-controlled action should logically reset this timer. However, the following functions, which are owner-controlled and modify important contract data or perform asset operations, do not reset the deadline:


2. Affected Functions

contractInteractions()

  • Description: Allows the owner to interact with other contracts, including sending Ether and calling functions.

  • Issue: This function represents a significant interaction with the contract and should reset the deadline, as it implies active management of the wallet.

  • Code:

    function contractInteractions(
    address _target,
    bytes calldata _payload,
    uint256 _value,
    bool _storeTarget
    ) external nonReentrant onlyOwner {
    (bool success, bytes memory data) = _target.call{value: _value}(_payload);
    require(success, "Interaction Failed");
    if (_storeTarget) {
    interactions[_target] = data;
    }
    }

createEstateNFT()

  • Description: Creates an NFT representing an underlying asset (e.g., real estate) and associates it with a value.

  • Issue: This is an important action that should reset the deadline, as it represents the owner actively managing their assets.

  • Code:

    function createEstateNFT(
    string memory _description,
    uint256 _value,
    address _asset
    ) external onlyOwner {
    uint256 nftID = nft.createEstate(_description);
    nftValue[nftID] = _value;
    assetToPay = _asset;
    }

removeBeneficiary()

  • Description: Removes a beneficiary from the beneficiaries array.

  • Issue: Modifying the list of beneficiaries is a critical action that should reset the deadline.

  • Code:

    function removeBeneficiary(address _beneficiary) external onlyOwner {
    uint256 indexToRemove = _getBeneficiaryIndex(_beneficiary);
    delete beneficiaries[indexToRemove];
    }

Impact

Premature Inheritance

  • If the owner actively uses these functions but does not trigger other functions that update the deadline, beneficiaries might be able to claim the inheritance prematurely because the deadline will have expired, even though the owner is technically active. The owner loses control over the inheritance logic, and it may be executed prematurely.


Tools Used

  • Manual Code Review


Recommendations

1. Call _setDeadline() in Missing Functions

Modify the following functions to include a call to _setDeadline() at the end of their execution:

contractInteractions()

function contractInteractions(
address _target,
bytes calldata _payload,
uint256 _value,
bool _storeTarget
) external nonReentrant onlyOwner {
(bool success, bytes memory data) = _target.call{value: _value}(_payload);
require(success, "Interaction Failed");
if (_storeTarget) {
interactions[_target] = data;
}
+ _setDeadline();
}

createEstateNFT()

function createEstateNFT(
string memory _description,
uint256 _value,
address _asset
) external onlyOwner {
uint256 nftID = nft.createEstate(_description);
nftValue[nftID] = _value;
assetToPay = _asset;
+ _setDeadline();
}

removeBeneficiary()

function removeBeneficiary(address _beneficiary) external onlyOwner {
uint256 indexToRemove = _getBeneficiaryIndex(_beneficiary);
delete beneficiaries[indexToRemove];
+ _setDeadline();
}

2. Consider a Specific Modifier

  • Create a modifier to verify the user is an owner and set the deadline.

modifier onlyOwnerAndSetDeadline() {
if (msg.sender != owner) {
revert NotOwner(msg.sender);
}
_setDeadline();
_;
}
  • Update the functions to use this modifier instead of onlyOwner:

- function removeBeneficiary(address _beneficiary) external onlyOwner {
+ function removeBeneficiary(address _beneficiary) external onlyOwnerAndSetDeadline {
uint256 indexToRemove = _getBeneficiaryIndex(_beneficiary);
delete beneficiaries[indexToRemove];
}
Updates

Lead Judging Commences

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

functions do not reset the deadline

Support

FAQs

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