Skip to content
Business logic Audit finding Intermediate

Protocol markets are incompatible with rebasing tokens

Markets store a lender's deposit as a fixed scaled balance, so when a rebasing token changes every holder's balance the lender's recorded claim does not follow it. Lenders could therefore lose funds, with the extra balance only reachable by the borrower.

MiloTruck Follow with 0xStalin, GREY-HAWK-REACH and 5 others

Originally disclosed on Code4rena

Submitted by MiloTruck, also found by 0xStalin, GREY-HAWK-REACH, devival, J4X, DarkTower, YusSecurity, and InAllHonesty

Some tokens (eg. AMPL), known as rebasing tokens, have dynamic balances. This means that the token balance of an address could increase or decrease over time.

However, markets in the protocol are unable to handle such changes in token balance. When lenders call depositUpTo(), the amount of assets they deposit is stored as a fixed amount in account.scaledBalance:

WildcatMarket.sol#L56-L65

    uint104 scaledAmount = state.scaleAmount(amount).toUint104();
    if (scaledAmount == 0) revert NullMintAmount();

    // Transfer deposit from caller
    asset.safeTransferFrom(msg.sender, address(this), amount);

    // Cache account data and revert if not authorized to deposit.
    Account memory account = _getAccountWithRole(msg.sender, AuthRole.DepositAndWithdraw);
    account.scaledBalance += scaledAmount;
    _accounts[msg.sender] = account;

Afterwards, when lenders want to withdraw their assets, the amount of assets that they can withdraw will be based off this value.

Therefore, since a lender’s scaledBalance is fixed and does not change according to the underlying asset balance, lenders will lose funds if they deposit into a market with a rebasing token as the asset.

For example, if AMPL is used as the market’s asset, and AMPL rebases to increase the token balance of all its users, lenders in the market will still only be able to withdraw the original amount they deposited multiplied by the market’s interest rate. The underlying increase in AMPL will not accrue to anyone, and is only accessible by the borrower by calling borrow().

Impact

If a market uses a rebasing tokens as its asset, lenders will lose funds when the asset token rebases.

Recommended Mitigation

Consider implementing a token blacklist in the protocol, such as in WildcatArchController, and adding all rebasing tokens to this blacklist.

Additionally, consider documenting that markets are not compatible with rebasing tokens.

Assessed type

ERC20

laurenceday (Wildcat) acknowledged, but disagreed with severity and commented:

This is a Low that we can flag up to borrowers deploying. Not interested in maintaining a token whitelist or blacklist, as it goes against the point that we don’t intervene.

0xTheC0der (judge) commented:

  1. I cannot find any info within the scope of this audit that rebasing tokens are OOS or unsupported. Please let me know, in case I overlooked it.
  2. Rebasing tokens, like stETH to name a “central” example, are no novelty in the DeFi space anymore and users expect DeFi protocols to be compatible with them when no further notice is provided.

Note: For full discussion, see here.


The original report as published on Code4rena, by MiloTruck. 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 market records deposits as a fixed scaled balance rather than tracking the underlying token balance, so rebases are not reflected in lender claims.

Impact

Lenders in a market whose asset is a rebasing token would lose funds when the token rebases, with the increase accessible only to the borrower.

What the attacker needed

Market uses a rebasing token as asset; token rebases after deposit

The fix

The report recommends blacklisting rebasing tokens in the protocol and documenting that markets are incompatible with them; the project acknowledged the issue but declined to keep a token list.

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.

Some tokens automatically change how many units every holder has, for example increasing everyone's balance over time. This protocol records each deposit as a fixed number of units, so when the token changes those numbers the record no longer matches reality. The lender can only take out the old amount, and the extra tokens sit in the market where the borrower can take them.

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 MiloTruck

View all

35 more disclosed reports, best first.

More from The Wildcat Protocol

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.