Skip to content
Smart contracts Audit finding Advanced

Potential flash loan attack vulnerability in `getPrice` function of CurveOracle

The getPrice function in CurveOracle uses the spot price of tokens in a Curve LP pool to calculate the LP token's USD value, which can be manipulated via a flash loan. An attacker could skew the minimum price calculation and profit at the expense of other users.

Bauer Follow with helpMePlease

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-04-blueberry-judging/issues/123

Found by

Bauer, helpMePlease

Summary

During a security review of the getPrice function in the CurveOracle, a potential flash loan attack vulnerability was identified.

Vulnerability Detail

The getPrice function retrieves the spot price of each token in a Curve LP pool, calculates the minimum price among them, and multiplies it by the virtual price of the LP token to determine the USD value of the LP token. If the price of one or more tokens in the pool is manipulated, this can cause the minimum price calculation to be skewed, leading to an incorrect USD value for the LP token. This can be exploited by attackers to make a profit at the expense of other users.

Impact

This vulnerability could potentially allow attackers to manipulate the price of tokens in Curve LP pools and profit at the expense of other users. If exploited, this vulnerability could result in significant financial losses for affected users.

Code Snippet

https://github.com/sherlock-audit/2023-04-blueberry/blob/96eb1829571dc46e1a387985bd56989702c5e1dc/blueberry-core/contracts/oracle/CurveOracle.sol#L122

Tool used

Manual Review

Recommendation

use TWAP to determine the prices of the underlying assets in the pool.

The original report as published on Sherlock, by Bauer. 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

Likely the oracle relies on spot prices from a Curve LP pool without time-weighting, making it vulnerable to flash loan price manipulation.

Impact

This could allow attackers to manipulate token prices in Curve LP pools and profit at the expense of other users, potentially causing significant financial losses.

What the attacker needed

Flash loan capability; manipulable Curve LP pool

The fix

The recommendation is to use a time-weighted average price (TWAP) to determine the prices of the underlying assets in the pool.

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 flash loan is a loan that must be borrowed and repaid within the same transaction, often used to temporarily manipulate prices. The oracle (a service that provides price data) reads the current price directly from a pool, so an attacker can use a flash loan to push that price around and trick the system into valuing an asset incorrectly.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by Bauer

View all

17 more disclosed reports, best first.

More from Blueberry Update #3

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.