Skip to content
Audit finding Intermediate

Newly Registered Assets Skew Consultation Results

When a new token pair is registered, the TWAP oracle's consultation returns a skewed price because the native asset amount defaults to zero while the Chainlink price is valid, causing the sum to favour USD. An attacker could exploit this incorrect price to manipulate protocol actions that rely on the oracle.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood

Impact

The TwapOracle.consult() function iterates over all token pairs which belong to either VADER or USDV` and then calculates the price of the respective asset by using both UniswapV2 and Chainlink price data. This helps to further protect against price manipulation attacks as the price is averaged out over the various registered token pairs.

If a new asset is added by first registering the token pair and aggregator, the consultation result for that token pair will remain skewed until the next update interval. This is due to the fact that the native asset amount will return 0 due to the default price1Average value being used. However, the Chainlink oracle will return a valid result. As a result, the query will be skewed in favour of sumUSD resulting in incorrect consultations.

I’d classify this issue as high risk as the oracle returns false results upon being consulted. This can lead to issues in other areas of the protocol that use this data in performing sensitive actions.

Proof of Concept

Tools Used

Manual code review.

Recommended Mitigation Steps

Consider performing proper checks to ensure that if pairData.price1Average._x == 0, then the Chainlink aggregator is not queried and not added to sumUSD. Additionally, it may be useful to fix the current check to assert that the pairData.price1Average.mul(1).decode144() result is not 0, found here. require(sumNative != 0) is used to assert this, however, this should be require(pairData.price1Average.mul(1).decode144() != 0) instead.

SamSteinGG (Vader) confirmed

The TWAP oracle module has been completely removed and redesigned from scratch as LBTwap that is subject of the new audit.

The original report as published on Code4rena, by leastwood. 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 does not check that the native asset average price is non-zero before including the Chainlink price, so a default zero value skews the consultation result.

Impact

The oracle returns false results, which could lead to issues in other protocol areas that use this data for sensitive actions.

What the attacker needed

New token pair is registered; consultation occurs before next update interval

The fix

The TWAP oracle module was completely removed and redesigned from scratch as LBTwap, which is subject to a new audit.

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 price oracle is a service that tells a smart contract the current price of an asset. Here, the oracle combines two sources: a decentralised exchange (Uniswap) and a price feed (Chainlink). When a new asset is added, one source gives zero while the other gives a real number, so the combined price is wrong. This wrong price could be used by attackers to trick the protocol.

More by leastwood

View all

70 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.