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

Failure to Reset Deadline in Critical Functions Enables Premature Takeover of Contract

Summary

The InheritanceManager contract is expected to reset the deadline to 90 days from the last interaction time. However, this functionality is missing in the InheritanceManager.sol::contractInteractions, InheritanceManager.sol::createEstateNFT, and InheritanceManager.sol::removeBeneficiary functions. This omission allows beneficiaries to take over the contract, even when the owner has recently interacted with it. This defeats the purpose of the lock time, which is intended to safeguard against premature inheritance while the owner remains active.

Vulnerability Details

The following test case demonstrates the issue and can be added to InheritanceManagerTest.t.sol.

function test_interacting_with_contract_does_not_reset_deadline()public{
// Deploy an example contract to interact with
ExampleContract exampleContract = new ExampleContract();
vm.startPrank(owner);
// Add user1 as a beneficiary to the Inheritance manager
im.addBeneficiery(user1);
// Emulate not interacting with the contract for 90 days plus
vm.warp(block.timestamp + im.TIMELOCK() +1);
bytes memory payload = abi.encodeWithSignature("setNumber(uint256)", 1);
// Interact with the example contract
// Interacting should reset the deadline time
im.contractInteractions(address(exampleContract), payload, 0 , true);
// creatin Estate Nft
im.createEstateNFT("Something awesome", 10 ether, address(1));
vm.stopPrank();
vm.prank(user1);
// User1 calling inherit to function to inherit the contract
// Inheritance works even when interaction with a contract has just been done
im.inherit();
address newOwner = im.getOwner();
uint256 getNumber = exampleContract.number();
// asserting that user1 successful inherited the contract
vm.assertEq(newOwner, user1);
// asserting that interaction with external contract works successfully
vm.assertEq(getNumber, 1);
}

Impact

Premature contract takeover, compromising the owner's control despite recent activity.

Tools Used

Foundry Test

Recommendations

Ensure that the deadline is reset each time these critical functions are invoked. Below is a proposed fix:

contract InheritanceManager is Trustee{
function contractInteractions(address _target, bytes calldata _payload, uint256 _value, bool _storeTarget)
external
nonReentrant
onlyOwner
{
+ _setDeadline();
// other relevant codes
}
function createEstateNFT(string memory _description, uint256 _value, address _asset) external onlyOwner {
+ _setDeadline();
// Other relevant codes
}
function removeBeneficiary(address _beneficiary) external onlyOwner {
+ _setDeadline();
// Other relevant codes
}
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 9 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.

Give us feedback!