Oracle does not treat upward and downward price movement the same in validity checks, causing safety issues in oracle usage
The NFT floor price oracle calculates price deviation as a ratio of the larger to the smaller value, which treats a 50% increase and a 33% decrease as the same deviation. This makes the oracle too permissive for price increases and too restrictive for price decreases, potentially allowing unsafe price updates.
Submitted by Trust
NFTFloorOracle retrieves ERC721 prices for ParaSpace. maxPriceDeviation is a configurable parameter, which limits the change percentage from current price to a new feed update. We can see how priceDeviation is calculated and compared to maxPriceDeviation in _checkValidity:
priceDeviation = _twap > _priorTwap
? (_twap * 100) / _priorTwap
: (_priorTwap * 100) / _twap;
// config maxPriceDeviation as multiple directly(not percent) for simplicity
if (priceDeviation >= config.maxPriceDeviation) {
return false;
}
return true;
The large number minus small number must be smaller than maxPriceDeviation. However, the way it is calculated means price decrease is much more sensitive and likely to be invalid than a price increase.
10 -> 15, priceDeviation = 15 / 10 = 1.5
15 -> 10, priceDeviation = 15 / 10 = 1.5
From 10 to 15, price rose by 50%. From 15 to 10, price dropped by 33%. Both are the maximum change that would be allowed by deviation parameter. The effect of this behavior is that the protocol will be either too restrictive in how it accepts price drops, or too permissive in how it accepts price rises.
Impact
Oracle does not treat upward and downward price movement the same in validity checks, causing safety issues in oracle usage.
Recommended Mitigation Steps
Use a percentage base calculation for both upward and downward price movements.
WalidOfNow (Paraspace) commented:
Going from 10 to 15 is 50% and from 15 to 10 is 33% percent. This is desired behaviour here. Why should we treat 33% as 50%?
That is exactly the point of this submission. Right now, you are treating both price movements (10-15, 15-10) the same, even though one is 50% and the other is 33%.
You are being far too permissive in upward price changes compared to downward changes, when accepting deviations.
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 deviation is computed as a ratio of the larger value to the smaller value, which is asymmetric for increases versus decreases.
What the attacker needed
Oracle update with price change
The fix
The deviation should be calculated as a percentage change relative to the prior price for both upward and downward movements.
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 service that feeds external data, like prices, into a smart contract. This oracle checks if a new price is too different from the old one, but it uses a formula that treats a 50% rise and a 33% drop as equally large changes. That means it might accept a big price increase that it should reject, or reject a small price drop that it should accept.