Skip to content
DoS Audit finding Intermediate

UniswapV2/SushiwapLPAdapter update the wrong token

The update function in the UniswapV2/Sushiswap LP adapter incorrectly calls the router's update with the LP token itself instead of the underlying token, causing infinite recursion and gas exhaustion. An attacker could trigger this function to cause a denial of service.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel

The UniswapV2LPAdapter/SushiswapV2LPAdapter.update function retrieves the underlying from the LP token pair (_asset) but then calls router.update(_asset, _proof) which is the LP token itself again. This will end up with the router calling this function again recursively.

Impact

This function fails as there’s an infinite recursion and eventually runs out of gas.

Recommendation

The idea was most likely to update the underlying price which is used in _getPrice as uint256 eAvg = cssr.getExchangeRatio(_underlying, weth);.

Call router.update(underlying, _proof) instead. Note that the _proof does not necessarily update the underlying <> WETH pair, it could be any underlying <> keyAsset pair.

ryuheimat (Mochi) confirmed

The original report as published on Code4rena, by cmichel. 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

The update function passes the LP token address instead of the underlying token address to the router's update function, causing it to call itself recursively.

What the attacker needed

None

The fix

The function should be fixed by calling `router.update(underlying, _proof)` instead of using the LP token address.

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.

This is a bug in a smart contract that handles liquidity pool tokens. The function that is supposed to update the price of the underlying token accidentally calls itself repeatedly, like a loop that never ends, which uses up all the gas (the fee paid for computation) and fails. An attacker could call this function to make it fail, potentially disrupting the system.

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 cmichel

View all

196 more disclosed reports, best first.

More from Mochi contest

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.