Usage of slot 0 to get sqrtPriceLimitX96 can be easily manipulated #46
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-27
🤖_03_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/ronin-chain/katana-v3-contracts/blob/03c80179e04f40d96f06c451ea494bb18f2a58fc/src/core/KatanaV3Pool.sol#L43
Vulnerability details
The
sqrtPriceX96
is derived from `slot0(), which can be easily manipulate.struct Slot0 {
// the current price
uint160 sqrtPriceX96;
// the current tick
int24 tick;
// the most-recently updated index of the observations array
uint16 observationIndex;
// the current maximum number of observations that are being stored
uint16 observationCardinality;
// the next maximum number of observations to store, triggered in observations.write
uint16 observationCardinalityNext;
// the numerator of the current protocol fee which is a ratio of the swap fee
uint8 feeProtocolNum;
// the denominator of the current protocol fee which is a ratio of the swap fee
uint8 feeProtocolDen;
// whether the pool is locked
bool unlocked;
}
This report below inspired this bug report and it is similar to this situatiom
Example: https://solodit.cyfrin.io/issues/h-02-use-of-slot0-to-get-sqrtpricelimitx96-can-lead-to-price-manipulation-code4rena-maia-dao-ecosystem-maia-dao-ecosystem-git
Recommended Mitigation Steps
Use the
TWAP
function to get the value ofsqrtPriceX96
.Assessed type
Oracle
The text was updated successfully, but these errors were encountered: