Skip to content
Business logic Audit finding Intermediate

Adding pair of the same foreignAsset would replace oracle of earlier entry

Oracles were stored keyed only by the foreign asset rather than by the specific trading pair, so adding a new pair for an asset that already had one silently overwrote the oracle used by the earlier pair. An attacker or careless admin adding a pair could therefore change the price source for an existing pair unexpectedly.

gzeon Follow

Originally disclosed on Code4rena

Submitted by gzeon

Oracles are mapped to the foreignAsset but not to the specific pair. Pairs with the same foreignAsset (e.g. UniswapV2 and Sushi) will be forced to use the same oracle. Generally this should be the expected behavior but there are also possibility that while adding a new pair changed the oracle of an older pair unexpectedly.

Proof of Concept

https://github.com/code-423n4/2021-12-vader/blob/9fb7f206eaff1863aeeb8f997e0f21ea74e78b49/contracts/lbt/LiquidityBasedTWAP.sol#L271

        oracles[foreignAsset] = oracle;

Recommended Mitigation Steps

Bind the oracle to pair instead

SamSteinGG (Vader) confirmed


The original report as published on Code4rena, by gzeon. 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 mapping is keyed by the foreign asset alone instead of by the asset pair, so a second registration for the same asset overwrites the first entry.

Impact

Adding a new pair for an asset that already has one could silently change the oracle used by the older pair, potentially feeding it incorrect prices.

What the attacker needed

Ability to add a pair for an existing asset

The fix

The oracle should be bound to the specific pair rather than to the foreign asset alone.

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 the component that tells a contract what an asset is worth. Here the contract saved one oracle per asset instead of one per trading pair, so registering a second pair for the same asset replaced the oracle the first pair was relying on, which could make that first pair report wrong prices.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by gzeon

View all

46 more disclosed reports, best first.

More from Vader Protocol contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.