code-423n4 / 2021-09-sushitrident-2-findings

0 stars 0 forks source link

Timestamp underflow error in `swap` function of `ConcentratedLiquidityPool` #90

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

broccoli

Vulnerability details

Impact

In the swap function of ConcentratedLiquidityPool, the following line of code seems to handle the timestamp overflow problem happening in year 2106:

uint256 diff = timestamp - uint256(lastObservation); /// @dev Underflow in 2106.

However, the subtraction is not within an unchecked statement. Thus an integer underflow still occurs when the block.timestamp overflows the maximum of uint256.

Proof of Concept

Referenced code: ConcentratedLiquidityPool.sol#L314

Recommended Mitigation Steps

Add an unchecked statement around the referenced line of code.