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.
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;
}
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 thecNoteover destroying it.The sponsor confirmed, and because this finding shows unconditional loss of assets, I 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 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.