Reward rates can be changed through flash borrows
The reward rate for a market can be manipulated by temporarily inflating its total borrows through a flash loan or miner-ordered transaction bundle, then calling the permissionless refresh function. An attacker can thus increase rewards in markets where they are a large participant, taking rewards from other users.
Based Loans
Originally disclosed on Code4rena
The rewards per market are proportional to their totalBorrows which can be changed by a large holder who deposits lots of collateral, takes out a huge borrow in the market, updates the rewards, and then unwinds the position. They’ll only pay gas fees as the borrow / repay can happen in the same block.
The Comptroller.refreshCompSpeeds function only checks that the single transaction is called from an EOA, but miners (or anyone if a miner offers services like flash bundles for flashbots) can still run flash-loan-like attacks by first sending a borrow tx increasing the totalBorrows, then the refreshCompSpeeds transaction, and then the repay of the borrow, as miners have full control over the transaction order of the block.
The new rate will then persist until the next call to refreshCompSpeeds.
Attackers have an incentive to drive up the rewards in markets they are a large supplier/borrower in.
The increased rewards that the attacker receives are essentially stolen from other legitimate users.
Recommend making it an admin-only function or use a time-weighted total borrow system similar to Uniswap’s price oracles.
ghoul-sol (Based Loans) confirmed:
Restricting
Comptroller.refreshCompSpeedsfunction to admin only would centralize an ability to update speeds. A better solution may be a bot that keeps track of markets utilizations and updates speeds when needed. That will also give a way to community to participate.Also, higher rewards would mean that all participants are getting them and that would bring even more liquidity to the given market and decrease attackers earnings. Attacker could keep moving the liquidity from market to market but everyone would follow quite quickly. If that actually happens, admin has a way to stop the rewards and make
refreshCompSpeedsadmin-only function as last resolution because comptroller is using proxy pattern.
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 reward update function relies on the current total borrows, which can be temporarily inflated within a single transaction or block, and the function is callable by any externally owned account.
Impact
The attacker could increase rewards in markets where they are a large supplier or borrower, effectively stealing rewards from other legitimate users; the new rate persists until the next refresh.
What the attacker needed
Ability to borrow large amounts (flash loan or capital); or miner collaboration for transaction ordering; no special permissions needed to call refreshCompSpeeds
The fix
The report recommends making the function admin-only or using a time-weighted total borrow system; the project confirmed but did not state a fix was applied.
How it was found
- Deposit a large amount of collateral.
- Take out a huge borrow in the target market, increasing totalBorrows.
- Call refreshCompSpeeds to update the reward rate based on the inflated totalBorrows.
- Repay the borrow and unwind the position, all within the same block.
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 this lending protocol, the interest rewards given to users depend on how much is borrowed in each market. Someone can borrow a huge amount for just one transaction, trigger a reward update while the borrowed amount is artificially high, then repay it all in the same block. This makes the reward rate stay high, benefiting the attacker at the expense of other users.
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.