This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Dug - The price from StableOracleDAI
is returned with the incorrect number of decimals
#236
Labels
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
High
A valid High severity issue
Reward
A payout will be made for this issue
Comments
github-actions
bot
added
High
A valid High severity issue
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
labels
Jun 5, 2023
This was referenced Jun 5, 2023
Closed
Closed
Closed
This was referenced Jun 5, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
High
A valid High severity issue
Reward
A payout will be made for this issue
Dug
high
The price from
StableOracleDAI
is returned with the incorrect number of decimalsSummary
The price returned from the
getPriceUSD
function of theStableOracleDAI
is scaled up by1e10
, which results in 28 decimals instead of the intended 18.Vulnerability Detail
In
StableOracleDAI
thegetPriceUSD
function is defined as follows...The assumption is made that the
DAIWethPrice
is 8 decimals, and is therefore multiplied by1e10
in the return statement to scale it up to 18 decimals.The other price feeds used in the protocol are indeed received with decimals, however, the Chainlink DAI/ETH price feed returns a value with 18 decimals as can be seen on their site.
https://docs.chain.link/data-feeds/price-feeds/addresses
Impact
This means that the price returned from the
getPriceUSD
function is scaled up by1e10
, which results in 28 decimals instead of the intended 18, drastically overvaluing the DAI/USD price.This will result in the USSD token price being a tiny fraction of what it is intended to be. Instead of being pegged to $1, it will be pegged to $0.0000000001, completely defeating the purpose of the protocol.
For example, if a user calls
USSD.mintForToken
, supplying DAI, they'll be able to mint1e10
times more USSD than intended.Code Snippet
https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/oracles/StableOracleDAI.sol#L33-L53
Tool used
Manual Review
Recommendation
Remove the
* 1e10
from the return statement.The text was updated successfully, but these errors were encountered: