The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: medium
Invalid

All of the USD pair price feeds doesn't have 8 decimals, token price can be overpriced

Summary

SmartVaultV3 contract assumes all of the USD pair chinlink price feeds have 8 decimals but there are certain token's USD feed has a different decimals

Vulnerability Details

In SmartVaultV3 contract, function tokenToEurAvg() and tokenToEur() is used to calculate price of token to eur in many functions:

function tokenToEur(ITokenManager.Token memory _token, uint256 _tokenValue) external view returns (uint256) {
    Chainlink.AggregatorV3Interface tokenUsdClFeed = Chainlink.AggregatorV3Interface(_token.clAddr);
    uint256 scaledCollateral = _tokenValue * 10 ** getTokenScaleDiff(_token.symbol, _token.addr);
    (,int256 _tokenUsdPrice,,,) = tokenUsdClFeed.latestRoundData();
    uint256 collateralUsd = scaledCollateral * uint256(_tokenUsdPrice);
    (, int256 eurUsdPrice,,,) = clEurUsd.latestRoundData();
    return collateralUsd / uint256(eurUsdPrice);
}

Same as tokenToEurAvg(), this function assumped that decimals of asset -> usd and eur -> usd is the same, which is eequal to 8. Both is taked from latestRoundData() function of chainlink aggregator. But problem is there are token that have chainlink feed that do not have 8 decimals, like [AMPL / USD feed](https://etherscan.io/address/0xe20CA8D7546932360e37E9D72c1a47334af57706#readContract have 18 decimals). If these tokens is used, it will break the protocol. Like AMPL token, collateral token will be overpriced 10 ** 10 times

Impact

Attacker can abusing it to minting more EUROs token than he should.

Tools Used

Manual review

Recommendations

Currently, i only see decimals of the price feed is 8 or 18, so the fix could be implement everytime these functions are used by checking decimals of both feed, and division with 10 ** 10 if the decimals in chainlink feed of token -> usd is 18. But for improble fix, when there might be data feeds that have lower decimals, that check should be implemented at these functions.

Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

chainlink-decimals

informational/invalid

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

chainlink-decimals

informational/invalid

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.