Underflow could happened when calculating Uniswap V3 position's fee growth and can cause operations to revert #10
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
H-04
primary issue
Highest quality submission among a set of duplicates
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2023-12-particle/blob/main/contracts/libraries/Base.sol#L318-L342
Vulnerability details
Impact
When operations need to calculate Uniswap V3 position's fee growth, it used similar function implemented by uniswap v3. However, according to this known issue : Uniswap/v3-core#573. The contract is implicitly relies on underflow/overflow when calculating the fee growth, if underflow is prevented, some operations that rely on fee growth will revert.
Proof of Concept
It can be observed that current implementation of
getFeeGrowthInside
not allow underflow/overflow to happen when calculatingfeeGrowthInside0X128
andfeeGrowthInside1X128
, because the contract used solidity 0.8.23.https://github.com/code-423n4/2023-12-particle/blob/main/contracts/libraries/Base.sol#L318-L342
This could impact crucial operation that rely on this call, such as liquidation, could revert unexpectedly. This behavior is quite often especially for pools that use lower fee.
Coded PoC :
Add the following test to
/test/OpenPosition.t.sol
:Also modify
FEE
inside/test/Base.t.sol
to500
:Run the test :
Log output :
It can be observed that the liquidation revert due to the underflow.
Tools Used
Manual review.
Recommended Mitigation Steps
Use unchecked when calculating
feeGrowthInside0X128
andfeeGrowthInside1X128
.Assessed type
Error
The text was updated successfully, but these errors were encountered: