You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 26, 2023. It is now read-only.
github-actionsbot opened this issue
Mar 1, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
/** @notice Calculates total quantity of token0 and token1 in both positions (and unused in the ICHIVault) @param total0 Quantity of token0 in both positions (and unused in the ICHIVault) @param total1 Quantity of token1 in both positions (and unused in the ICHIVault)*/function getTotalAmounts()
publicviewoverridereturns (uint256total0, uint256total1)
{
(, uint256base0, uint256base1) =getBasePosition();
(, uint256limit0, uint256limit1) =getLimitPosition();
total0 =IERC20(token0).balanceOf(address(this)).add(base0).add(limit0);
total1 =IERC20(token1).balanceOf(address(this)).add(base1).add(limit1);
}
where getBasePosition and getLimitPosition fetch available liquidity from UniswapV3 pools.
A big swap using a flash-loan can push the liquidity to one side only, meaning that a position will contain only token1 for example. If that is the most valuable token according to base oracles, the lp token itself will appear more valuable.
This will allow the attacker to drain the protocol, by borrowing against over valued collateral.
Impact
An attacker can drain the protocol by borrowing against overvalued collateral.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
cergyk
high
Ichi vault LP oracle is vulnerable to price manipulation with flashloan
Summary
The protocol relies on an oracle to price Ichi Lp shares, unfortunately it is vulnerable to price manipulation using a flash-loan.
Vulnerability Detail
The function getTotalAmounts:
https://github.com/sherlock-audit/2023-02-blueberry/blob/main/contracts/oracle/IchiLpOracle.sol#L27
is defined as such in Ichi vaults:
where
getBasePosition
andgetLimitPosition
fetch available liquidity from UniswapV3 pools.A big swap using a flash-loan can push the liquidity to one side only, meaning that a position will contain only token1 for example. If that is the most valuable token according to base oracles, the lp token itself will appear more valuable.
This will allow the attacker to drain the protocol, by borrowing against over valued collateral.
Impact
An attacker can drain the protocol by borrowing against overvalued collateral.
Code Snippet
Tool used
Manual Review
Recommendation
One can use the same logic as the IchiVault itself uses to protect against price manipulation on UniswapV3: using a twap oracle as reference and revert if the price has deviated too much in the same block:
https://etherscan.deth.net/address/0x683F081DBC729dbD34AbaC708Fa0B390d49F1c39#code
line 2621:
Duplicate of #20
The text was updated successfully, but these errors were encountered: