Skip to content
DoS Audit finding Intermediate

Price Accumulators Overflow in GTELaunchpadV2Pair contract Causes AMM-wide DoS

The price accumulators in the GTE AMM pair contract are updated with checked arithmetic, so they will revert once they reach the maximum uint256 value instead of wrapping around. This would permanently block the _update function, breaking liquidity operations and TWAP oracle updates, eventually halting the entire AMM.

AasifUsmani Follow with 0rpse, 0xanony and 8 others

Originally disclosed on Code4rena

Submitted by AasifUsmani, also found by 0rpse, 0xanony, 0xIconart, dimulski, djshan_eden, johnyfwesh, KonstantinVelev, nonso72, prk0, and ret2basic

  • launchpad/uniswap/GTELaunchpadV2Pair.sol #L136-L137
  • launchpad/uniswap/GTELaunchpadV2Pair.sol #L2

The GTE AMM is a Uniswap V2 fork but uses Solidity >0.8.0. Solidity ≥0.8 introduces built-in overflow/underflow checks, which revert instead of wrapping around.

In Uniswap V2, price accumulators (price0CumulativeLast, price1CumulativeLast) are explicitly designed to overflow naturally. This is both expected and documented behavior: cumulative prices are uint256 counters that wrap around over time, and TWAP calculations rely on differences in values, not absolute numbers.

In GTE’s implementation of GTELaunchpadV2Pair, because the accumulators are updated under Solidity >0.8.0 checked arithmetic, once they approach uint256.max, the addition will revert instead of overflowing. This causes:

  • Permanent DoS of _update().
  • All liquidity mint/burn operations break.
  • TWAP oracle updates fail, making the AMM price feed unusable.
  • Eventually, the entire AMM grinds to a halt.

Both Uniswap V2 docs and Rareskills blogs explicitly mentions to implement the price accumulators inside the unchecked blocks to let the calculation overflow and prevent DoS.

Here is the Rareskills’s blog about why to use unchecked blocks with price accumulators:

  1. https://rareskills.io/post/build-your-own-uniswap
  2. https://rareskills.io/post/twap-uniswap-v2#uniswap-v2-does-not-store-lookback-or-the-denominator

This is what’s mentioned in Rareskills blog:

But this is an important point you should always remember price0CumulativeLast and price1CumulativeLast are only updated on lines 79 and 80 in the code above (orange circle), and they can only increase until they overflow. There is no mechanism make them “go down.” They always increase with every call to _update. This means they accumulate prices ever since the pool is launched, which could be a very long time.

This explains why it is mandatory to use unchecked blocks while calculating price accumulators.

Recommended mitigation steps

To mitigate this critical bug, just wrap the price accumulators in unchecked block so that the calculation will skip the overflow/underflow checks:-

function _update(
        uint256 balance0,
        uint256 balance1,
        uint112 _reserve0,
        uint112 _reserve1,
        uint112 newLaunchpadFee0,
        uint112 newLaunchpadFee1
    ) private {
       //----- Remaining logic -----
           unchecked{
            price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
            price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
           }

       //----- Remaining logic -----

View detailed Proof of Concept


The original report as published on Code4rena, by AasifUsmani. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the price accumulator additions are not wrapped in an unchecked block, so Solidity's built-in overflow check reverts when the counters exceed uint256.max.

Impact

The overflow revert would permanently block _update, breaking all liquidity mint/burn operations and TWAP oracle updates, eventually halting the entire AMM.

What the attacker needed

Accumulators reach uint256.max

The fix

The price accumulator additions should be wrapped in an unchecked block so they can overflow and wrap around as intended.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

In many automated market maker (AMM) contracts, cumulative price counters are designed to overflow and wrap around, because only the difference between two readings matters. This contract uses a newer version of Solidity that automatically reverts on overflow, so the counters will eventually stop working. That would freeze key operations like adding or removing liquidity and updating the price oracle.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by AasifUsmani

View all

8 more disclosed reports, best first.

More from GTE Perps and Launchpad

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.