Total LP supply & total debt accrual is wrong
The total debt and total LP supply are not increased by the full new interest on each accrual, only by the interest of the updated user. This leads to an incorrect utilization ratio and thus wrong borrow rates, causing less debt to accrue than expected.
Submitted by cmichel
The total debt and total supply only increase when debt/supply is minted to the user when it should increase by the entire new interest amount on each accrual.
function accrueAccount(address _account) public {
_distributeReward(_account);
// accrue only updates cumulativeInterestRate to the newInterest
// newInterest is not added to total debt or total LP supply!
accrue();
// instead total debt / total LP supply is increased here by a much smaller amount, the new interest specific for the updating user
_accrueAccountInterest(_account);
if (_account != feeRecipient()) {
_accrueAccountInterest(feeRecipient());
}
}
The borrow rates (see borrowRatePerBlock) are wrong due to the wrong utilization ratio: The borrow utilization rate uses LPToken.totalSupply. Assume there’s a single lender supplying $100k, another single borrower borrows $70k (ignoring irrelevant details like liquidation and the borrower not putting up collateral for the sake of the argument). After some time debt accrued and the supplier “updates” by calling accrue (but the borrower does not update), this increases the LP total supply to, say, $110k, while total debt is not updated. The utilization rate and thus the borrow rate is now less than before (from 70/100=70% to 70/110=63%). In reality, it should have increased as the supplier interest is only a fraction of the borrower accumulated debt. From now on less debt than expected accrues until the borrower is updated and total debt is increased. To get the correct borrow rates in the current system, every borrower and every supplier would need to be updated on every accrual which is infeasible.
Recommend doing it like Compound/Aave, increase total debt and total supply on each accrual by the total new interest (not by the specific user’s interest only). This might require a bigger refactor because the LP token is treated as a (“lazy-evaluated”) rebasing token and the total supply is indeed the total tokens in circulation LP.totalSupply() and one cannot mint the new interest to all users at once in each accrue. That’s why Compound uses an interest-bearing token and tracks total supply separately and Aave uses a real rebasing token that dynamically scales the balance in balanceOf and must not be updated individually for each user.
talegift (Wild Credit) confirmed but disagreed with severity:
The issue seems to only impact interest rate calculation. It doesn’t allow anyone to steal the funds.
Severity should be set to 1.
I’m making this medium risk as no funds are lost but the accounting is basically incorrect.
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 accrue function only updates the total debt and total LP supply by the interest of the specific account being updated, not by the total new interest accrued across all accounts.
Impact
The borrow rate becomes incorrect, causing less debt to accrue than expected; no funds are lost, but the accounting is wrong.
What the attacker needed
A lending pool with accrue function; multiple users (suppliers and borrowers)
The fix
The total debt and total supply should be increased by the total new interest on each accrual, similar to Compound or Aave, which may require a refactor of the LP token model.
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. The contract should update the total amount owed and total supplied whenever interest is added. Here, it only updates for the person who triggers the update, so the totals become inaccurate. This makes the interest rate calculation wrong, meaning borrowers pay less interest than they should.
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.