Skip to content
Audit finding Intermediate

CurveTricryptoOracle incorrectly assumes that WETH is always the last token in the pool which leads to bad LP pricing

The CurveTricryptoOracle contract incorrectly assumes that WETH is always the last token in a tricrypto pool, but many pools have a different token in that position. This causes the LP price to be massively overvalued, leading to overborrowing and potential protocol insolvency.

0x52 Follow with Vagner

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-07-blueberry-judging/issues/98

Found by

0x52, Vagner

CurveTricryptoOracle assumes that WETH is always the last token in the pool (tokens[2]). This is incorrect for a majority of tricrypto pools and will lead to LP being highly overvalued.

Vulnerability Detail

CurveTricryptoOracle.sol#L53-L63

    if (tokens.length == 3) {
        /// tokens[2] is WETH
        uint256 ethPrice = base.getPrice(tokens[2]);
        return
            (lpPrice(
                virtualPrice,
                base.getPrice(tokens[1]),
                ethPrice,
                base.getPrice(tokens[0])
            ) * 1e18) / ethPrice;
    }

When calculating LP prices, CurveTricryptoOracle#getPrice always assumes that WETH is the second token in the pool. This isn't the case which will cause the LP to be massively overvalued.

There are 6 tricrypto pools currently deployed on mainnet. Half of these pools have an asset other than WETH as token[2]:

    0x4ebdf703948ddcea3b11f675b4d1fba9d2414a14 - CRV
    0x5426178799ee0a0181a89b4f57efddfab49941ec - INV
    0x2889302a794da87fbf1d6db415c1492194663d13 - wstETH

Impact

LP will be massively overvalued leading to overborrowing and protocol insolvency

Code Snippet

CurveTricryptoOracle.sol#L48-L65

Tool used

Manual Review

Recommendation

There is no need to assume that WETH is the last token. Simply pull the price for each asset and input it into lpPrice.

Discussion

IAm0x52

Escalate

This is not a dupe of #105. This will cause a large number of tricrypto pools to be overvalued which presents a serious risk to the protocol.

sherlock-admin2

Escalate

This is not a dupe of #105. This will cause a large number of tricrypto pools to be overvalued which presents a serious risk to the protocol.

You've created a valid escalation!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

Shogoki

Agree. This is not a duplicate of #105 This can become its own main report and #20 is a duplicate of it.

There were some issues with (de)duplication. I would resolve like this. #98 is the duplicate with #20 #105 is duplicate with #42

hrishibhat

Result: High Has duplicates This is a valid high issue based on the description

sherlock-admin2

Escalations have been resolved successfully!

Escalation status:

The original report as published on Sherlock, by 0x52. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 oracle hard-codes the assumption that WETH is the last token in every tricrypto pool, rather than dynamically fetching the price for each token in its actual position.

Impact

LP tokens could be massively overvalued, leading to overborrowing and protocol insolvency.

What the attacker needed

None

The fix

The oracle should fetch the price for each asset in the pool and use those prices directly in the lpPrice calculation, without assuming a fixed token order.

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 provides asset prices to a smart contract. This oracle assumed a specific token (WETH) was always in a certain position in a pool, but some pools have a different token there. As a result, the oracle calculated the pool's value incorrectly, making it seem much more valuable than it really is, which could let attackers borrow too much money.

More by 0x52

View all

211 more disclosed reports, best first.

More from Blueberry Update #3

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.