Price feed can be manipulated
The price feed derives prices by simulating a trade against Uniswap pair reserves, which an attacker can shift drastically with flash loans to produce almost arbitrary prices. Wrong prices break core contract functions such as margin borrowing and liquidations.
Marginswap
Originally disclosed on Code4rena
Anyone can trigger an update to the price feed by calling PriceAware.getCurrentPriceInPeg(token, inAmount, forceCurBlock=true). If the update window has passed, the price will be computed by simulating a Uniswap-like trade with the amounts. This simulation uses the reserves of the Uniswap pairs which can be changed drastically using flash loans to yield almost arbitrary output amounts, and thus prices. Wrong prices break the core functionality of the contracts such as borrowing on margin, liquidations, etc.
Recommend against using the Uniswap spot price as the real price. Uniswap itself warns against this and instead recommends implementing a TWAP price oracle using the price*CumulativeLast variables.
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 uses the instantaneous spot price from Uniswap pair reserves, which is trivially movable within one transaction, instead of a time-weighted average price.
Impact
An attacker could force almost arbitrary prices, which breaks core functionality such as borrowing on margin and liquidations.
What the attacker needed
Flash loan access; update window has passed
The fix
The price oracle should be replaced with a TWAP oracle built on the cumulative price variables rather than the spot reserves.
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 current price of a token, and it works this out by looking at how much of each token sits in a trading pool. Someone can borrow a huge amount of tokens for a single transaction, dump them into the pool to skew that balance, and the contract then reads a fake price. The borrowed tokens are returned in the same transaction, so the attacker keeps the profit without needing real capital.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.