Skip to content
Business logic Audit finding Intermediate

Rebalance will fail if a market has high utilization

The rebalance function attempts to withdraw all tokens from each money market, but in peer-to-peer lending protocols like Compound or Aave, full withdrawal may be impossible when utilisation is high. An attacker could cause rebalancing to fail by creating a liquidity crunch in a single market.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel

The AssetManager.rebalance function iterates through the markets and withdraws all tokens in the moneyMarkets[i].withdrawAll call.

Note that in peer-to-peer lending protocols like Compound/Aave the borrower takes the tokens from the supplier and it might not be possible for the supplier to withdraw all tokens if the utilisation ratio of the market is high.

See this check for example in Compound’s cToken.

Impact

Rebalancing will fail if a single market has a liquidity crunch.

Recommended Mitigation Steps

Withdraw only what’s available and rebalance on that instead of trying to pull all tokens from each market first. Admittedly, this might be hard to compute for some protocols.

kingjacob (Union) acknowledged

GalloDaSballo (judge) commented:

Agree with the finding, at this time this potential vulnerability is a feature of the protocol

I recommend in the long term, that the sponsor rewrites the rebalance function to account for liquidity crunches

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

Likely the rebalance function assumes all tokens can be withdrawn from each market, ignoring the liquidity constraints of peer-to-peer lending protocols.

What the attacker needed

A market with high utilisation

The fix

The rebalance function should be rewritten to withdraw only what is available and rebalance based on that, rather than trying to pull all tokens from each market first.

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 lending protocols, people deposit tokens that others borrow. If most tokens are borrowed, the protocol may not have enough to let depositors withdraw everything at once. This report says a function that tries to withdraw all tokens from such markets will fail if one market is heavily borrowed.

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 Union Finance 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.