getBorrowRate returns rate per year instead of per block
The getBorrowRate function in NoteInterest returns an annual rate instead of a per-block rate, while CToken's borrowRatePerBlock directly uses that value. This causes interest calculations to be massively inflated, leading to incorrect yield and loss of value.
Submitted by Lambda, also found by Chom
https://github.com/Plex-Engineer/lending-market-v2/blob/2646a7676b721db8a7754bf5503dcd712eab2f8a/contracts/NoteInterest.sol#L118 https://github.com/Plex-Engineer/lending-market-v2/blob/2646a7676b721db8a7754bf5503dcd712eab2f8a/contracts/CToken.sol#L209
According to the documentation in InterestRateModel, getBorrowRate has to return the borrow rate per block and the function borrowRatePerBlock in CToken directly returns the value of getBorrowRate. However, the rate per year is returned for NoteInterest. Therefore, using NoteInterest as an interest model will result in completely wrong values.
Recommended Mitigation Steps
Return baseRatePerBlock.
Alex the Entreprenerd (judge) commented:
The warden has shown that the borrowRate is returning per-year values instead of per-block values.
The effect of this is that the accounting will be magnified massively.
While impact should be mostly loss of value to interest and incorrect yield, due to the math being 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
Root cause
Likely, the getBorrowRate function in NoteInterest returns a per-year rate instead of the required per-block rate.
Impact
Interest accounting is magnified massively, causing loss of value to interest and incorrect yield.
What the attacker needed
Using NoteInterest as interest model
The fix
The getBorrowRate function should return the per-block rate (baseRatePerBlock) instead of the per-year rate.
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.
Smart contracts often calculate interest per block, not per year. Here, a function that should give the per-block rate mistakenly gives the per-year rate, making interest charges far too high.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.