LP tokens cannot be valued because ICHI cannot be priced by oracle, causing all new open positions to revert
The oracle for ICHI LP tokens relies on Chainlink or Band to price the underlying ICHI token, but neither supports ICHI, so the price lookup fails. As a result, any attempt to open a new position using the IchiVaultSpell reverts, making the protocol unusable for that vault.
Source: https://github.com/sherlock-audit/2023-02-blueberry-judging/issues/152
Found by
obront
Summary
In order to value ICHI LP tokens, the oracle uses the Fair LP Pricing technique, which uses the prices of both individual tokens, along with the quantities, to calculate the LP token value. However, this process requires the underlying token prices to be accessible by the oracle. Both Chainlink and Band do not support the ICHI token, so the function will fail, causing all new positions using the IchiVaultSpell to revert.
Vulnerability Detail
When a new Ichi position is opened, the ICHI LP tokens are posted as collateral. Their value is assessed using the IchiLpOracle#getPrice() function:
function getPrice(address token) external view override returns (uint256) {
IICHIVault vault = IICHIVault(token);
uint256 totalSupply = vault.totalSupply();
if (totalSupply == 0) return 0;
address token0 = vault.token0();
address token1 = vault.token1();
(uint256 r0, uint256 r1) = vault.getTotalAmounts();
uint256 px0 = base.getPrice(address(token0));
uint256 px1 = base.getPrice(address(token1));
uint256 t0Decimal = IERC20Metadata(token0).decimals();
uint256 t1Decimal = IERC20Metadata(token1).decimals();
uint256 totalReserve = (r0 * px0) /
10**t0Decimal +
(r1 * px1) /
10**t1Decimal;
return (totalReserve * 1e18) / totalSupply;
}
This function uses the "Fair LP Pricing" formula, made famous by Alpha Homora. To simplify, this uses an oracle to get the prices of both underlying tokens, and then calculates the LP price based on these values and the reserves.
However, this process requires that we have a functioning oracle for the underlying tokens. However, Chainlink and Band both do not support the ICHI token (see the links for their comprehensive lists of data feeds). As a result, the call to base.getPrice(token0) will fail.
All prices are calculated in the isLiquidatable() check at the end of the execute() function. As a result, any attempt to open a new ICHI position and post the LP tokens as collateral (which happens in both openPosition() and openPositionFarm()) will revert.
Impact
All new positions opened using the IchiVaultSpell will revert when they attempt to look up the LP token price, rendering the protocol useless.
Code Snippet
Tool used
Manual Review
Recommendation
There will need to be an alternate form of oracle that can price the ICHI token. The best way to accomplish this is likely to use a TWAP of the price on an AMM.
Discussion
Gornutz
There is additional oracles for assets not supported by chainlink or band but just not in scope of this specific audit.
hrishibhat
Based on the context there are no implementations for getting the price of the ICHI token. Considering this a valid issue.
SergeKireev
Escalate for 31 USDC
Impact stated is medium, since positions cannot be opened and no funds are at risk. The high severity definition as stated per Sherlock docs:
This vulnerability would result in a material loss of funds and the cost of the attack is low (relative to the amount of funds lost). The attack path is possible with reasonable assumptions that mimic on-chain conditions. The vulnerability must be something that is not considered an acceptable risk by a reasonable protocol team.
sherlock-admin
Escalate for 31 USDC
Impact stated is medium, since positions cannot be opened and no funds are at risk. The high severity definition as stated per Sherlock docs:
This vulnerability would result in a material loss of funds and the cost of the attack is low (relative to the amount of funds lost). The attack path is possible with reasonable assumptions that mimic on-chain conditions. The vulnerability must be something that is not considered an acceptable risk by a reasonable protocol team.
You've created a valid escalation for 31 USDC!
To remove the escalation from consideration: Delete your comment. To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
hrishibhat
Escalation accepted
This is a valid medium Also Given that this is an issue only for the Ichi tokens and impact is only unable to open positions.
sherlock-admin
Escalation accepted
This is a valid medium Also Given that this is an issue only for the Ichi tokens and impact is only unable to open positions.
This issue's escalations have been accepted!
Contestants' payouts and scores will be updated according to the changes made on this issue.
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 design assumes that every underlying token has a Chainlink or Band price feed, but ICHI does not, so the price lookup reverts.
Impact
All new positions opened using the IchiVaultSpell will revert, rendering the protocol useless for that vault; no funds are at risk.
What the attacker needed
ICHI token lacks Chainlink/Band price feed; User attempts to open ICHI position
The fix
An alternate oracle that can price the ICHI token, such as a TWAP from an AMM, should be used.
How it was found
- A user calls openPosition or openPositionFarm to open a new ICHI position.
- The ICHI LP tokens are posted as collateral.
- The protocol calls IchiLpOracle#getPrice() to value the LP tokens.
- getPrice() calls base.getPrice() for each underlying token, including ICHI.
- The call to base.getPrice() for ICHI fails because no price feed exists.
- The transaction reverts, so the position cannot be opened.
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 needs a price for each token to calculate the value of collateral. Here, the price source for one token (ICHI) does not exist, so the calculation fails and the transaction is cancelled. This means users cannot open new positions with that vault.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.