Skip to content
Business logic Audit finding Intermediate

setDebtInterestApr should accrue debt first

The setDebtInterestApr function changes the debt interest rate without first accruing the debt, so the new rate is applied retroactively to the unaccrued period on the next accrue() call. Borrowers can incur more debt than they should.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel, also found by pedroais

NFTVault.sol#L212

The setDebtInterestApr changes the debt interest rate without first accruing the debt. This means that the new debt interest rate is applied retroactively to the unaccrued period on next accrue() call.

It should never be applied retroactively to a previous time window as this is unfair & wrong. Borrowers can incur more debt than they should.

Recommended Mitigation Steps

Call accrue() first in setDebtInterestApr before setting the new settings.debtInterestApr.

spaghettieth (JPEG’d) confirmed

spaghettieth (JPEG’d) resolved and commented:

Fixed in jpegd/core#4.


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

The setDebtInterestApr function updates the interest rate without first calling accrue() to record interest up to the current time.

Impact

Borrowers could incur more debt than they should because the new rate is applied retroactively to the unaccrued period.

What the attacker needed

None

The fix

The function should call accrue() before setting the new debt interest rate; the report states it was fixed.

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.

In a lending system, interest builds up over time and is recorded when someone calls a function to update the debt. If you change the interest rate without first recording the interest earned so far, the new rate gets applied to the past period too. That means borrowers are charged the new rate for time that has already passed, which is unfair and can make them owe more than expected.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by cmichel

View all

196 more disclosed reports, best first.

More from JPEG'd contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.