Skip to content
Smart contracts Audit finding Intermediate

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.

Lambda Follow

Originally disclosed on Code4rena

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.

nivasan1 (Canto) confirmed

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.


The original report as published on Code4rena, by Lambda. 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

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.

More by Lambda

View all

64 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.