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

1 stars 0 forks source link

nalus - Duration overflow #74

Closed sherlock-admin closed 2 years ago

sherlock-admin commented 2 years ago

nalus

high

Duration overflow

Summary

Since _duration's upper limit maxLockDuration is uint256, casting it to uint(64) can result in overflow and saving the wrong duration in depositsOf.

Impact

Overflow can cause the wrong duration to be saved in the storage and consequentially wrong balance.

Code Snippet

https://github.com/Merit-Circle/merit-liquidity-mining/blob/ce5feaae19126079d309ac8dd9a81372648437f1/contracts/TimeLockPool.sol#L102

https://github.com/Merit-Circle/merit-liquidity-mining/blob/ce5feaae19126079d309ac8dd9a81372648437f1/contracts/TimeLockPool.sol#L182

Tool used

VS code and me

Recommendation

Add a condition which checks that uint64(block.timestamp) + duration <= type(uint64).max

Duplicate of #66