This repository has been archived by the owner on May 26, 2023. It is now read-only.
ctf_sec - Refund timestamp expiration is incorrectly extended #113
Labels
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
Non-Reward
This issue will not receive a payout
ctf_sec
medium
Refund timestamp expiration is incorrectly extended
Summary
Refund deadline is incorrectly extended
Vulnerability Detail
In the current implementation,
When the user fund the bounty contract, he can set the expiration time:
according to the natspec, the expiration is:
/// @param _expiration The duration until the deposit becomes refundable
As shown in the test case:
the parameter thirtySeconds means that the funded amout of token expires in thirty seconds.
The funder can also have the also to extend the deposit fund expiration time:
which calls:
which calls:
note the core logic:
let us go through an example:
the depositTime is at timestamp 100
the expiration is 10, meaning after 10 seconds, the funder can claim the deposit
now the funder calls extendDeposit and wants to extend the expiration by 5 seconds.
at timestamp 105, 105 is smaller than 100 + 10, therefore the code below executes:
expiration time is extended by 5 seconds, which 10 seconds + 5 seconds = 15 seconds.
at timestamp 150, 150 is larger than 100 + 10, therefore the code below executes:
expirationTime time is set to 150 - 100 + 5 seconds = 45 seconds.
the users means to extend the deposit to 5 seconds but extends the expirationTime to 45 times, which is much longer than user expected.
Impact
The user can unexpectedly extend the deposit refund deadline to a time longer than he expected.
Code Snippet
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/DepositManager/Implementations/DepositManagerV1.sol#L75-L106
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/BountyCore.sol#L94-L121
Tool used
Manual Review
Recommendation
We recommend the protocol revisit the logic below to make sure the expiration extended is not longer than user expected.
Duplicate of #552
The text was updated successfully, but these errors were encountered: