Description
In createEstateNFT
, removeBeneficiary
, and contractInteractions
the deadline is not being reset after the owner performs actions. This does not align with the protocols intended functionality.
For the sake of this bug, assume setDeadline
has been initialised correctly in the constructor.
Impact
The deadline
is not reset despite the owner performing actions. This can lead to an unintended inheritance trigger.
Proof of Concept
Add the following code to InheritanceManagerTest.t.sol
:
function test_createEstateNFT_doesNotResetDeadline() public {
vm.startPrank(owner);
uint256 initialDeadline = im.getDeadline();
vm.warp(block.timestamp + 10 days);
im.createEstateNFT("My House", 1000 ether, address(usdc));
uint256 newDeadline = im.getDeadline();
vm.stopPrank();
assertLe(newDeadline, initialDeadline, "setDeadline should be reset after creating estate NFT");
}
Tools Used
Manual review, Foundry
Recommended Mitigation
In order for the timer to be reset after each onlyOwner
action, add the code shown below.
function createEstateNFT(string memory _description, uint256 _value, address _asset) external onlyOwner {
uint256 nftID = nft.createEstate(_description);
nftValue[nftID] = _value;
assetToPay = _asset;
+ _setDeadline();
}
function removeBeneficiary(address _beneficiary) external onlyOwner {
uint256 indexToRemove = _getBeneficiaryIndex(_beneficiary);
delete beneficiaries[indexToRemove];
+ _setDeadline();
}
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();
}