This repository has been archived by the owner on May 26, 2023. It is now read-only.
HonorLt - Incorrect new expiration when extending expired deposit #552
Labels
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
Non-Reward
This issue will not receive a payout
Sponsor Disputed
The sponsor disputed this issue's validity
HonorLt
medium
Incorrect new expiration when extending expired deposit
Summary
extendDeposit
assigns the wrong new expiration time when the deposit has expired.Vulnerability Detail
extendDeposit
calculates the new expiration differently depending if the deposit has expired or not:As you can see, when it has expired, the new expiration time is calculated this way:
block.timestamp - depositTime[_depositId] + _seconds;
This basically translates to the time elapsed since the deposit plus new seconds.
I believe this calculation is wrong. It operates on the elapsed time with no anchor to any specific timestamp. To illustrate why I think this is wrong, let's see this example:
1676471998 - 1676471088 + 30 = 940
Clearly, this is a wrong timestamp. It has already passed.
Impact
Now it is practically impossible to extend an expired deposit.
Code Snippet
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/BountyCore.sol#L108-L114
Tool used
Manual Review
Recommendation
I think a simple solution would be to continue from the current timestamp when the deposit is expired:
expiration[_depositId] = block.timestamp + _seconds
.Another more precise option would be allowing users to specify not the seconds but the end timestamp.
The text was updated successfully, but these errors were encountered: