Closed sherlock-admin closed 2 years ago
The PoC is not valid.
await timeLockPool.connect(alice).extendLock(0, minDuration);
The "bottom bread slice" transaction does not bring the total time of the lock back to 10 minutes, it extends the current lock end by 10 minutes. Current lock at that moment is 4 years because of the "top bread slice" transaction.
I ran the PoC test and check Alice's deposit after all transactions: see that deposit.end
minus deposit.start
equals maxLockDuration
. This means that she needs to wait 4 years to withdraw tokens, and not 10 minutes as stated. Withdraw transaction reverts with TooSoonError even if more than 10 minutes goes by
Any additional information/evidence/code snippet is appreciated.
Jeiwan
high
Rewards can be stolen via lock duration extension and reduction
Summary
In the TimeLockPool contract, users deposit and lock funds for a certain duration and get pro-rata amounts of shares in exchange. The longer the duration the more shares they get. The amount of shares a user holds determines the amount of rewards tokens they can claim.
The extendLock function allows depositors to extend or reduce the lock duration of their funds. This function allows malicious actors to extend a lock duration to the maximal value before reward tokens are distributed and reduce it to the minimal value right after claiming their share of rewards. This allows to steal rewards from honest users who locked their funds for longer durations.
Vulnerability Detail
The root cause of the vulnerability is that the extendLock function allows to reduce a lock duration at any time:
Since this functionality is not timelocked or limited in any way, depositors are only forced to lock funds for up to the minimal lock duration.
Impact
Reward tokens can be stolen from honest users by malicious actors by manipulating a lock duration around the time when rewards are distributed. The cost of the attack is low since attacker's fund can be locked in the contract only for up to the minimal lock duration, which is only 10 minutes.
Code Snippet
The following PoC demonstrates a sandwich attack that steals rewards:
Tool used
Manual Review
Recommendation
Multiple options can be considered: