Wrong price scale for GasOracle
The GasOracle contract multiplies raw values from two Chainlink oracles without scaling them to a common 18-decimal format, assuming the result is already in 18 decimals. If the oracles use different decimals, the gas price can be heavily inflated or under-reported.
Submitted by cmichel
The GasOracle uses two chainlink oracles (GAS in ETH with some decimals, USD per ETH with some decimals) and multiplies their raw return values to get the gas price in USD.
However, the scaling depends on the underlying decimals of the two oracles and could be anything. But the code assumes it’s in 18 decimals.
“Returned value is USD/Gas * 10^18 for compatibility with rest of calculations”
There is a toWad function that seems to involve scaling but it is never used.
The impact is that, If the scale is wrong, the gas price can be heavily inflated or under-reported.
Recommend checking chainlink.decimals() to know the decimals of the oracle answers and scale the answers to 18 decimals such that no matter the decimals of the underlying oracles, the latestAnswer function always returns the answer in 18 decimals.
raymogg (Tracer) confirmed and disagreed with severity:
Disagree with severity as while the statement that the underlying decimals of the oracles could be anything, we will be using production Chainlink feeds for which the decimals are known at the time of deploy.
This is still however an issue as you don’t want someone using different oracles (eg non Chainlink) that have different underlying decimals and not realising that this contract will not support that.
Marking this a high-risk issue as it poses a big threat to users deploying their own markets
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 contract assumes oracle return values are already scaled to 18 decimals and multiplies them directly without checking or adjusting for the actual decimals of each oracle.
Impact
If the scale is wrong, the gas price can be heavily inflated or under-reported, posing a big threat to users deploying their own markets.
What the attacker needed
Oracles with non-18 decimals; deployment using such oracles
The fix
The code should check each oracle's decimals and scale the answers to 18 decimals so that latestAnswer always returns a value in 18 decimals.
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.
A smart contract called GasOracle calculates gas price in USD by multiplying numbers from two price feeds. Each feed reports numbers with a different number of decimal places, but the contract assumes the result always has 18 decimal places. If the feeds use different decimals, the calculated price can be wildly wrong, which could harm users.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.