The price calculation in the asset distribution mechanism does not take the Chainlink
Oracle decimals into calculation.
distributeAssets
assumes and inexplicitly requires the asset's USD feed's decimals to be the same
than the EUR/USD feed's decimals (decimals = 8).
The current implementation of the distributeAssets
function of LiquidationPool assumes that the
ASSET/USD price decimals is the same than the EUR/USD price decimals.
The current EUR/USD price decimals is 8.
However, there exist tokens with USD price feed's decimals != 8.
When the tokens with USD price feed's decimals != 8, the token price calculation in distributeAssets
will be incorrect.
This vulnerability doesn't seem to be exploitable for now.
But, if new tokens are supported in the support, it might be the case.
That is why severity is medium and not high.
A distributed asset can be under priced or over priced due to incorrect calculations during distribution.
In case of over pricing, this could lead to the burning of stakers' EUROs position for a small amount of input asset.
Scope:
https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L220
https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L218
In the following calculations, costInEuros
could be incorrect if assertPriceUsd
and priceEurUsd
are not using the same decimals.
In distributeAssets
, consider adding an explicit check to make sure that ASSET/USD feed's
decimals == EUR/USD feed's decimals. The following diff shows such a fix.
:warning: This vulnerability can also impact PriceCalculator.sol
which is out of the audit scope.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.