IchiLpOracle is extemely easy to manipulate due to how IchiVault calculates underlying token balances
The IchiLpOracle valued IchiVault LP positions using the pool's most recent slot0 price data, which is easy to move within a single transaction. An attacker could use large buys or sells to shift the LP composition and manipulate the oracle's valuation, causing loss of funds for the protocol and other users.
Source: https://github.com/sherlock-audit/2023-02-blueberry-judging/issues/20
Found by
carrot, obront, ctf_sec, cergyk, banditx0x, psy4n0n, 0x52
Summary
IchiVault#getTotalAmounts uses the UniV3Pool.slot0 to determine the number of tokens it has in it's position. slot0 is the most recent data point and is therefore extremely easy to manipulate. Given that the protocol specializes in leverage, the effects of this manipulation would compound to make malicious uses even easier.
Vulnerability Detail
function _amountsForLiquidity(
int24 tickLower,
int24 tickUpper,
uint128 liquidity
) internal view returns (uint256, uint256) {
(uint160 sqrtRatioX96, , , , , , ) = IUniswapV3Pool(pool).slot0();
return
UV3Math.getAmountsForLiquidity(
sqrtRatioX96,
UV3Math.getSqrtRatioAtTick(tickLower),
UV3Math.getSqrtRatioAtTick(tickUpper),
liquidity
);
}
IchiVault#getTotalAmounts uses the UniV3Pool.slot0 to determine the number of tokens it has in it's position. slot0 is the most recent data point and can easily be manipulated.
IchiLPOracle directly uses the token values returned by vault#getTotalAmounts. This allows a malicious user to manipulate the valuation of the LP. An example of this kind of manipulation would be to use large buys/sells to alter the composition of the LP to make it worth less or more.
Impact
Ichi LP value can be manipulated to cause loss of funds for the protocol and other users
Code Snippet
Tool used
Manual Review
Recommendation
Token balances should be calculated inside the oracle instead of getting them from the IchiVault. To determine the liquidity, use a TWAP instead of slot0.
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 trusted a spot price (slot0) from the pool instead of a time-weighted average, so the valuation could be moved within one transaction.
Impact
The LP value could be manipulated, which could cause loss of funds for the protocol and other users.
What the attacker needed
Ability to trade in the underlying pool
The fix
The oracle should calculate token balances itself and use a TWAP rather than slot0 to determine liquidity.
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.
An oracle is a contract that tells a protocol what something is worth. This oracle worked out the value of a liquidity position from the pool's latest price, which anyone can push around by trading in the same transaction. That let an attacker make the position look worth more or less than it really was.