Skip to content
Smart contracts Audit finding Intermediate

Underlying asset price oracle for CToken in BaseV1-periphery is inaccurate

The price oracle for the cNOTE token returns 1 instead of 1e18, making the token's price appear far too low. An attacker could exploit this incorrect price to borrow excessively or cause other financial damage in the lending market.

ladboy233 Follow

Originally disclosed on Code4rena

Submitted by ladboy233

https://github.com/Plex-Engineer/lending-market-v2/blob/443a8c0fed3c5018e95f3881a31b81a555c42b2d/contracts/Stableswap/BaseV1-periphery.sol#L489

Underlying asset price oracle for CToken in BaseV1-periphery is inaccurate.

Proof of Concept

    function getUnderlyingPrice(CToken ctoken) external override view returns(uint price) {
        IBaseV1Pair pair;
        uint8 stable;
        bool stablePair;
        address underlying;

        if (compareStrings(ctoken.symbol(), "cCANTO")) {
            stable = 0;
            underlying = address(wcanto);
        }
        //set price statically to 1 when the Comptroller is retrieving Price
        else if (compareStrings(ctoken.symbol(), "cNOTE") && msg.sender == Comptroller) {
            return 1; // Note price is fixed to 1
        }

We should not be return 1. 1 is 1 wei. We should be 10 ** 18

Tools Used

VIM

Recommended Mitigation Steps

We can return 10 ** 18

nivasan1 (Canto) confirmed

Alex the Entreprenerd (judge) commented:

The warden has shown what probably is a developer mistake, which will scale down the price of the cNOTE token to 1.

The sponsor confirms.

It should be noted that if cNOTE always returns 1e18 then the math for diff will always be zero, meaning the interest will exclusively be dictated by baseRatePerYear.

Because the sponsor confirms, and because the comments point to values “scaled by 1e18” I believe the finding to be valid, and since the “math is wrong”, I do agree with High Severity.


The original report as published on Code4rena, by ladboy233. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

Impact

The incorrect price could allow an attacker to manipulate the lending market, potentially borrowing more than allowed or causing financial loss, though the judge notes that returning 1e18 would also make interest calculations rely solely on the base rate.

What the attacker needed

Access to the lending market

The fix

The price should be returned as 10 ** 18 instead of 1.

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 price oracle tells a lending system how much a token is worth. Here, the oracle mistakenly said one token was worth only one tiny unit (1 wei) instead of the correct large number (1e18 wei). This wrong price could let someone borrow more than they should or break the system's maths.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by ladboy233

View all

47 more disclosed reports, best first.

More from Canto v2 contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.