sherlock-audit / 2022-10-merit-circle-judging

1 stars 0 forks source link

__141345__ - unit and curve.length need sanity check #97

Closed sherlock-admin closed 2 years ago

sherlock-admin commented 2 years ago

141345

medium

unit and curve.length need sanity check

Summary

If the curve.length is too large, unit could round down to 0, the subsequent function call will revert. Users might fail to extendLock() or increaseLock() and suffer a loss.

Vulnerability Detail

There is no 0 value check for unit when update the curve. If the length of new curve is too large, unit = maxLockDuration / (curve.length - 1) could round down to 0.

Impact

Some functions call getMultiplier() will revet, such as deposit(), extendLock(), increaseLock(), causing DoS. If users can not extendLock() or increaseLock(), they might suffer a loss.

Code Snippet

https://github.com/sherlock-audit/2022-10-merit-circle/blob/main/merit-liquidity-mining/contracts/TimeLockPool.sol#L308

https://github.com/sherlock-audit/2022-10-merit-circle/blob/main/merit-liquidity-mining/contracts/TimeLockPool.sol#L233-L246

Tool used

Manual Review

Recommendation

Add 0 check for unit when update the curve.

Duplicate of #10