Skip to content
Business logic Audit finding Intermediate

addFeedFor should check if inverse feed already exists

The addFeedFor function only checked whether a price feed for the given currency pair already existed in one direction, but not the inverse direction. This allowed two different oracles to be set for the same pair in opposite directions, potentially causing inconsistent currency conversions.

0x52 Follow

Originally disclosed on Code4rena

Submitted by 0x52, also found by DimitarDimitrov

Potentially inconsistent currency conversions.

Proof of Concept

addFeedFor requires that a price feed for the _currency _base doesn’t exist when adding a new price feed but doesn’t check if the inverse already exists. This means that two different oracles (potentially with different prices) could be used for _currency -> _base vs. _base -> _currency. Different prices would lead to inconsistent between conversion ratios depending on the direction of the conversion.

Recommended Mitigation Steps

Change L115 to: if (feedFor\[\_currency]\[\_base] != IJBPriceFeed(address(0)) || feedFor\[\_base]\[\_currency] != IJBPriceFeed(address(0))) revert PRICE_FEED_ALREADY_EXISTS()

mejango (Juicebox) confirmed

mejango (Juicebox) resolved:

PR with fix: PR #1

berndartmueller (warden) reviewed mitigation:

An additional check has been added to prevent adding a price feed for the inverse pair.


The original report as published on Code4rena, by 0x52. 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

The function only checked one direction of the currency pair when verifying if a feed already exists, missing the inverse pair.

Impact

Two different oracles could be used for the same currency pair in opposite directions, leading to inconsistent conversion ratios depending on the direction of the conversion.

What the attacker needed

Ability to call addFeedFor

The fix

The check was updated to also verify the inverse pair before allowing a new feed, and this was fixed in a pull request.

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 lets you add price feeds for currency pairs. It checked if a feed for A-to-B already existed, but forgot to check if a feed for B-to-A existed. So you could add two different feeds for the same pair, and the contract might use different prices depending on which way you convert.

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 0x52

View all

211 more disclosed reports, best first.

More from Juicebox Buyback Delegate

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.