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.
Submitted by ladboy233
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
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
diffwill always be zero, meaning the interest will exclusively be dictated bybaseRatePerYear.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.
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.