Skip to content
Audit finding Advanced

Oracle can be manipulted to consider only a single pair for pricing

The oracle values each pool's liquidity by multiplying reserves by a price, and an attacker could skew a single pair's reserves with a flash loan so that pool appears to hold an arbitrarily large amount. That would make all other pairs contribute negligibly, so if a Chainlink feed for one asset were faulty the oracle could be forced to price from that one pool.

TomFrenchBlockchain Follow

Originally disclosed on Code4rena

Submitted by TomFrenchBlockchain

Loss of resilience of oracle to a faulty pricing for a single pair.

Proof of Concept

In the oracle we calculate the TVL of each pool by pulling the reserves and multiplying both assets by the result of a supposedly manipulation resistant oracle (the oracle queries its previous value for USDV and pulls the foreign asset from chainlink).

https://github.com/code-423n4/2021-12-vader/blob/fd2787013608438beae361ce1bb6d9ffba466c45/contracts/lbt/LiquidityBasedTWAP.sol#L353-L383

This value can be manipulated by skewing the reserves of the underlying pair with a flashloan attack. An attacker can then make a pool appear with an arbitrarily large currentLiquidityEvaluation which will result in all other pairs contributing negligibly to the final result of the oracle.

This doesn’t result in loss of funds by itself afaict but should there be an issue for the chainlink price feed for the asset in any pool then an attacker can force the oracle to only use that pool for pricing USDV/VADER

Medium risk as “Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.” External requirements being a malfunctioning or deprecated chainlink pricefeed for any used asset.

Calculating TVL of the pool is equivalent to value of all LP tokens so for more information see this post: https://blog.alphafinance.io/fair-lp-token-pricing/

Recommended Mitigation Steps

Calculate fair reserves using the pool invariant and the fair prices of the two assets.

The above link contains a mitigates for Uniswap, a similar calculation would have to be performed which is specific for the Vader invariant.

SamSteinGG (Vader) disputed and commented:

The evaluation of liquidity for a particular pair is performed based on the reserves of the previous block rendering a flash loan attack impossible. Can the warden clarify how he is expecting this to be exploited?


The original report as published on Code4rena, by TomFrenchBlockchain. 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 oracle weights each pool by a liquidity value derived from spot reserves, so a single pool's reserves can be inflated to dominate the aggregate.

Impact

No funds are directly at risk, but if a Chainlink feed for any used asset malfunctions or is deprecated, an attacker could force the oracle to price from a single pool; the project disputed that the attack is possible because liquidity is evaluated from the previous block's reserves.

What the attacker needed

A faulty or deprecated Chainlink feed; ability to skew pool reserves (e.g. flash loan)

The fix

Fair reserves should be calculated from the pool invariant and the fair prices of both assets rather than from raw 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.

An oracle is a service that feeds prices into a smart contract. This one works out how much each trading pool is worth and combines the pools to get a price. The reporter says someone could temporarily distort one pool's balances so it looks huge, drowning out the other pools, but only matters if a price feed is already broken.

More by TomFrenchBlockchain

View all

28 more disclosed reports, best first.

More from Vader Protocol contest

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.