Return to site
Return to site

Bug Deep Dive #17

Incorrect inside fees calculation for uninitialized uniswap ticks causes positions funds being stuck in the contract - $4432

· Bug Deep Dive
Section image

PoolLib.getInsideFees calculates inside fees when current price is inside the position range as:

Section image

The issue is that this code doesn't handle uninitialized ticks. poolContract.ticks returns correct lowerFeeGrowthOutside amounts only for initialized ticks. For uninitialized ticks it returns 0. This means that for uninitialized ticks the feeGrowthInside amounts will be equal to feeGrowthGlobal.

As a result:

  • If maker position is created on uninitialized uniswap ticks while the current price is inside the position range, any further actions of this position will revert, with user funds in this position being stuck permanently;
  • Attacker can steal all diamond funds by collecting inflated fees.

For example, the first DoS scenario happens when node.liq.feeGrowthInside0X128/1X128 have been set to inflated values when the ticks were not initialized before, but newFeeGrowthInside0X128/1X128 return the post initialization values, so 0, which underflows, and the position gets stuck.

Section image

Alpha: study Uniswap well when integrating with it. In this case, the fact that unintialized ticks return 0 fee growth variables wasn't handled, leading to severe issues.

Conclusion

This finding would earn you $4432, and having a deep Uniswap knowledge would allow you to find it.

Full Report
Codebase

Subscribe
Previous
Bug Deep Dive #16
Next
Bug Deep Dive #18
 Return to site
Cookie Use
We use cookies to improve browsing experience, security, and data collection. By accepting, you agree to the use of cookies for advertising and analytics. You can change your cookie settings at any time. Learn More
Accept all
Settings
Decline All
Cookie Settings
Necessary Cookies
These cookies enable core functionality such as security, network management, and accessibility. These cookies can’t be switched off.
Analytics Cookies
These cookies help us better understand how visitors interact with our website and help us discover errors.
Preferences Cookies
These cookies allow the website to remember choices you've made to provide enhanced functionality and personalization.
Save