Skip to content
Business logic Audit finding Intermediate

Blocked accounts keep earning interest contrary to the WhitePaper

Blocked accounts' scaled balances are moved to an escrow contract that still earns interest, contrary to the whitepaper's claim that interest does not accrue in escrow. An attacker could not directly exploit this, but it means sanctioned lenders continue to accrue interest while blocked.

osmanozdemir1 Follow with QiuhaoLi, Infect3d and 8 others

Originally disclosed on Code4rena

Submitted by osmanozdemir1, also found by QiuhaoLi, Infect3d, crunch, 0xCiphky, circlelooper, Jiamin, 0xStalin, Juntao, rvierdiiev, and HChang26

Lines of code

https://github.com/code-423n4/2023-10-wildcat/blob/c5df665f0bc2ca5df6f06938d66494b11e7bdada/src/market/WildcatMarketConfig.sol#L79 https://github.com/code-423n4/2023-10-wildcat/blob/c5df665f0bc2ca5df6f06938d66494b11e7bdada/src/market/WildcatMarketBase.sol#L178

Proof of Concept

Lenders might be flagged as sanctioned by the ChainAnalysis oracle and these lenders can be blocked with the nukeFromOrbit() function or during a withdrawal execution. Both of these functions will call the internal _blockAccount() function.

https://github.com/code-423n4/2023-10-wildcat/blob/c5df665f0bc2ca5df6f06938d66494b11e7bdada/src/market/WildcatMarketBase.sol#L163

  function _blockAccount(MarketState memory state, address accountAddress) internal {

      // skipped for brevity
@>    if (scaledBalance > 0) {
        account.scaledBalance = 0;
        address escrow = IWildcatSanctionsSentinel(sentinel).createEscrow(
          accountAddress,
          borrower,
          address(this)
        );
        emit Transfer(accountAddress, escrow, state.normalizeAmount(scaledBalance));
@>      _accounts[escrow].scaledBalance += scaledBalance;

      // skipped for brevity
    }
  }

As we can see above, if the user’s scaled balance is greater than zero, an escrow contract is created for market tokens and the scaled token balance is transferred to the escrow contract.

In this protocol, there are two types of tokens: Underlying tokens, and market tokens. Market tokens are used for internal balance accounting and it is tracked with scaled balances. Underlying tokens are tracked with normalized balances. scaleFactor is the value that provides accumulated interest, and increment with every state update. scaled balances are multiplied by the scaleFactor and this will provide the normalized balances.

  • Scaled balances do earn interest.
  • Normalized balances do not earn interest.

According to the protocol’s WhitePaper (page 16), blocked accounts should not earn interest.

“The effect of this would be that an auxiliary escrow contract is deployed and the debt obligation of the borrower towards the lender is transferred to this new contract. Interest does not accrue within this contract from the time the debt is transferred, and the borrower is expected to immediately return the balance of funds due up to that time to the escrow contract.”

However, because the escrow contract holds scaled balances, these funds will keep earning interest. These scaled balances will be normalized when the funds are released (after the sanction is removed) according to that date’s scaleFactor.

Note: There might be two escrow contracts for the same lender if it is triggered during a withdrawal request. One with market tokens and the other with underlying tokens. The one with underlying tokens does not earn interest as expected. However, the escrow with the market tokens will still keep earning interest. I believe a blocked account earning interest contradicts the idea of the blocking.

Recommended Mitigation Steps

I think all of the scaled balances should be normalized before transferring to the escrow contract to stop earning interest.

Assessed type

Context

laurenceday (Wildcat) commented:

Error in whitepaper. Acknowledged (and embarrassing) but won’t fix.

Needs to account for growth in the event that the sanction is performed by a hostile (read: non-Chainalysis) actor in control of the oracle. Borrowers affected by this that are concerned about growth potential can close the market.

laurenceday (Wildcat) acknowledged

Note: For full discussion, see here.


The original report as published on Code4rena, by osmanozdemir1. 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 blocking function transfers the scaled balance directly to the escrow without normalising it first, so the escrow continues to accrue interest.

Impact

Blocked accounts continue to earn interest while in escrow, contradicting the whitepaper; the protocol acknowledged this as a whitepaper error and chose not to fix it.

What the attacker needed

Account is blocked by the oracle; account has a positive scaled balance

The fix

The scaled balance should be normalised before being transferred to the escrow contract, so that it stops earning interest.

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, interest is earned by holding 'scaled balances', which grow over time. When an account is blocked, its scaled balance is moved to a separate escrow contract, but because it is still a scaled balance, it keeps growing. The whitepaper said blocked funds should not earn interest, so this is a mismatch between the documentation and the code.

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 osmanozdemir1

View all

5 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.