Submitted by cmichel, also found by broccoli
The ConcentratedLiquidityPool.burn function performs an unsafe cast of a uint128 type to a signed integer.
Note that amount is chosen by the caller and when choosing amount = 2**128 - 1, this is interpreted as 0xFFFFFFFFF... = -1 as a signed integer. Thus -(-1)=1 adds 1 liquidity unit to the position
This allows an attacker to not only mint LP tokens for free but as this is the burn function it also redeems token0/1 amounts according to the unmodified uint128 amount which is an extremely large value.
I created this POC that implements a hardhat test and shows how to steal the pool tokens.
Choosing the correct amount of liquidity to burn and lower, upper ticks is not straight-forward because of two competing constraints:
This example shows how to steal 99% of the token0 pool reserves:
An attacker can steal the pool tokens.
Even though Solidity 0.8.x is used, type casts do not throw an error.
A SafeCast library must be used everywhere a typecast is done.
sarangparikh22 (Sushi) confirmed
