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
Tool used
Manual Review
Recommendation
use TWAP to determine the prices of the underlying assets in the pool.
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.