Skip to content
Smart contracts Audit finding Intermediate

AccountantDelegate : sweepInterest function will destroy the cnote in the contract.

The sweepInterest function in AccountantDelegate transfers all cnote tokens held by the contract to address 0, destroying them. This prevents users from repaying note tokens and causes interest calculations to be incorrect.

cccz Follow

Originally disclosed on Code4rena

Submitted by cccz, also found by WatchPug

When the user borrows note tokens, the AccountantDelegate contract provides note tokens and gets cnote tokens. Later, when the user repays the note tokens, the cnote tokens are destroyed and the note tokens are transferred to the AccountantDelegate contract. However, in the sweepInterest function of the AccountantDelegate contract, all cnote tokens in the contract will be transferred to address 0. This will prevent the user from repaying the note tokens, and the sweepInterest function will not calculate the interest correctly later.

Proof of Concept

https://github.com/Plex-Engineer/lending-market/blob/ab31a612be354e252d72faead63d86b844172761/contracts/Accountant/AccountantDelegate.sol#L74-L92 https://github.com/Plex-Engineer/lending-market/blob/ab31a612be354e252d72faead63d86b844172761/contracts/CToken.sol#L533

Recommended Mitigation Steps

    function sweepInterest() external override returns(uint) {

		uint noteBalance = note.balanceOf(address(this));
		uint CNoteBalance = cnote.balanceOf(address(this));

		Exp memory expRate = Exp({mantissa: cnote.exchangeRateStored()}); // obtain exchange Rate from cNote Lending Market as a mantissa (scaled by 1e18)
		uint cNoteConverted = mul_ScalarTruncate(expRate, CNoteBalance); //calculate truncate(cNoteBalance* mantissa{expRate})
		uint noteDifferential = sub_(note.totalSupply(), noteBalance); //cannot underflow, subtraction first to prevent against overflow, subtraction as integers

		require(cNoteConverted >= noteDifferential, "Note Loaned to LendingMarket must increase in value");

		uint amtToSweep = sub_(cNoteConverted, noteDifferential);

		note.transfer(treasury, amtToSweep);

-		cnote.transfer(address(0), CNoteBalance);

		return 0;
    }

tkkwon1998 (Canto) confirmed

Alex the Entreprenerd (judge) commented:

The warden has shown how, due to a programmer mistake, interest bearing Note will be burned.

It is unclear why this decision was made, and I believe the sponsor should look into redeeming the cNote over destroying it.

The sponsor confirmed, and because this finding shows unconditional loss of assets, I agree with High Severity.


The original report as published on Code4rena, by cccz. 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 a programming mistake: the sweepInterest function calls cnote.transfer(address(0), CNoteBalance) instead of redeeming or handling the cnote tokens properly.

Impact

This unconditionally destroys cnote tokens, preventing users from repaying note tokens and causing incorrect interest calculations.

What the attacker needed

None

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.

When you borrow tokens, the contract holds some cnote tokens as collateral. A function called sweepInterest is supposed to collect interest, but instead it sends all those cnote tokens to a burn address, destroying them. This means you cannot repay your loan and the interest calculation breaks.

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 cccz

View all

104 more disclosed reports, best first.

More from Canto

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.