Exchange rates from Compound are assumed with 18 decimals
The CTokenMultiOracle contract assumed Compound exchange rates always have 18 decimals, but the actual scaling depends on the underlying token's decimals. This could cause incorrect token pricing.
Submitted by shw
The CTokenMultiOracle contract assumes the exchange rates (borrowing rate) of Compound always have 18 decimals, while, however, which is not true. According to the Compound documentation, the exchange rate returned from the exchangeRateCurrent function is scaled by 1 * 10^(18 - 8 + Underlying Token Decimals) (and so does exchangeRateStored). Using a wrong decimal number on the exchange rate could cause incorrect pricing on tokens. See CTokenMultiOracle.sol #L110.
Recommend following the documentation and getting the decimals of the underlying tokens to set the correct decimal of a Source.
Thanks a lot for coming up with this. I had looked into how Compound defined the decimals and couldn’t find it.
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
The contract hardcoded 18 decimals for Compound exchange rates instead of calculating the correct scaling based on the underlying token's decimals.
Impact
Using a wrong decimal number on the exchange rate could cause incorrect pricing on tokens.
What the attacker needed
None
The fix
The issue was fixed by following the documentation and getting the decimals of the underlying tokens to set the correct decimal of a Source.
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.
Compound is a lending platform that gives you 'cTokens' representing your deposit. The exchange rate tells you how many underlying tokens one cToken is worth. The code assumed this rate always has 18 decimal places, but it actually varies with the token's decimals, so prices could be wrong.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.