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

No 90-day timer reset in some functions

Summary

Some functions that modify the contract when called by the owner do not reset the 90-day timer.

Vulnerability Details

According to the docs, assets can be dstributed to beneficiaries after a set period of wallet inactivity. The functions InheritanceManager::removeBeneficiary and InheritanceManager::contractInteractions should reset the 90-day timer, as they involve contract interactions and modifications.

Impact

Failure to reset the timer breaks the core assumption of the contract: beneficiaries should only inherit funds after 90 days of wallet inactivity.

Proof of Code

Add the following code to the InheritanceManagerTest.t.sol file within the InheritanceManagerTest contract (example for InheritanceManager::removeBeneficiary function).

function test_resetTimerAfterOwnerInteractionWithContractFail() external {
uint256 deadline;
uint256 expectedDeadline;
uint256 startTimestamp = 100;
vm.startPrank(owner);
vm.warp(startTimestamp);
im.addBeneficiery(user1);
deadline = im.getDeadline();
expectedDeadline = startTimestamp + 90 days;
assertEq(deadline, expectedDeadline);
skip(100);
// after executing below function, the timer should be to 90 days ahead
// but it's not happening
im.removeBeneficiary(user1);
vm.stopPrank();
deadline = im.getDeadline();
expectedDeadline = block.timestamp + 90 days;
assertNotEq(deadline, expectedDeadline);
}

Tools Used

  • Manual Review

  • Foundry

Recommended mitigation

The functions InheritanceManager::removeBeneficiary and InheritanceManager::contractInteractions should call the internal function InheritanceManager::_setDeadline to reset the 90-day timer after performing their operations.
Proposed changes:

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();
}
function removeBeneficiary(address _beneficiary) external onlyOwner {
uint256 indexToRemove = _getBeneficiaryIndex(_beneficiary);
delete beneficiaries[indexToRemove];
+ _setDeadline();
}

This ensures that any owner interaction resets the timer, maintaining the contract’s intended functionality.

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!