Skip to content
Audit finding Advanced

PriceAware uses prices from getAmountsOut

The PriceAware contract derives prices from an AMM's getAmountsOut function, whose returned values can be manipulated by an attacker using large capital or flash loans. Peg amount limits reduce but do not fully remove the impact of such manipulation.

Marginswap

Originally disclosed on Code4rena

getPriceFromAMM relies on values returned from getAmountsOut which can be manipulated (e.g. with the large capital or the help of flash loans). The impact is reduced with UPDATEMINPEGAMOUNT and UPDATEMAXPEGAMOUNT, however, it is not entirely eliminated.

Uniswap v2 recommends using their TWAP oracle: https://uniswap.org/docs/v2/core-concepts/oracles/

The original report as published on Code4rena. 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 contract trusts a spot price from an AMM's getAmountsOut, which reflects the pool's current balances and can be shifted within a single transaction.

Impact

An attacker could manipulate the price the contract reads, though the peg amount limits reduce the effect rather than eliminate it.

What the attacker needed

Ability to trade against the AMM pool; sufficient capital or a flash loan

The fix

The contract should use a time-weighted average price oracle as recommended by Uniswap v2 instead of the spot getAmountsOut value.

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.

A smart contract needs to know the price of a token, and it asks a trading pool (an automated market maker) for that price. An attacker can temporarily push that pool's price around by trading large amounts, so the contract reads a wrong price. The report says the project added limits to soften this, but the weakness remains.

More from Marginswap

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.