Skip to content
Business logic Audit finding Intermediate

Debt can be repaid with a depegged underlyingToken, which can be exploited by arbitrageurs and drives the market price of alToken to match the worst depegged underlyingToken

The repay function converts any accepted underlying token to debt at a fixed 1:1 ratio regardless of its market price, so a depegged token can repay the same nominal debt for less real value. An arbitrageur could mint alToken, buy the cheap depegged token, repay debt with it, withdraw collateral and sell the leftover alToken for profit, pushing the alToken price down to the depegged token's price.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug

AlchemistV2.sol#L1679-L1682

function _normalizeUnderlyingTokensToDebt(address underlyingToken, uint256 amount) internal view returns (uint256) {
    return amount * _underlyingTokens[underlyingToken].conversionFactor;
}

AlchemistV2.sol#L743-L786

function repay(address underlyingToken, uint256 amount, address recipient) external override lock returns (uint256) {
    ...
    uint256 credit = _normalizeUnderlyingTokensToDebt(underlyingToken, actualAmount);

    // Update the recipient's debt.
    _updateDebt(recipient, -SafeCast.toInt256(credit));
    ...

When repaying the debt with an underlyingToken, the amount in terms of the underlyingToken (adjusted for decimals) will always be taken in a 1:1 ratio/price for the subtrahend of the debt.

We believe this design is flawed and be exploited by arbitrageurs and eventually drives the market price of alToken to match the worst depegged underlyingToken.

Because if alToken is trading at a higher price against the depegged underlyingToken, the arbitrageur can always mint alToken and market sell for more depegged underlyingToken and repay the debt.

Proof of Concept

Given:

  • alUSD is trading at $1
  • minimumCollateralization: 4/3
When USDT is slightly depegged, and trading at $0.9:

An arbitrageur can:

  1. Deposit 100M USDC as collateral and mint 75M alUSD (100*0.75);
  2. Market buy 75M USDT with 67.5M alUSD (75*0.9) and repay the debt;
  3. Withdraw the 100M USDC collateral;
  4. Dump the remaining 7.5M alUSD (75-67.5) for profit.

This can be repeated until the market price of alUSD drops to $0.9, the same price as USDT.

Recommendation

Consider updating the repay() function and change to market buy using the underlyingToken to alToken and then burn() the alToken to reduce debt.

0xfoobar (Alchemix) acknowledged, disagreed with severity and commented:

This is a core design choice underlying the Alchemix system. Like-kind collateral and debt assumes that assets will hold their relationship. The onus lies on governance to choose safe collateral assets.

0xleastwood (judge) decreased severity to Medium and commented:

I agree with what was raised by the warden but disagree with the associated severity. Because user’s assets are tied to the underlying collateral, it makes sense that the a depegged token would be reflected in the price of alToken. As a result, arbitrageurs are free to profit off this by driving the price of alToken down to its true value.

I consider this to be medium risk because of an unlikely assumption made when considering the likelihood of a depeg event. Assets are not at direct risk, but value can be leaked under certain assumptions.


The original report as published on Code4rena, by WatchPug. 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 repay logic normalises the underlying token amount to debt using only a fixed conversion factor, ignoring the token's current market price relative to the debt asset.

Impact

Value could leak from the protocol and the alToken market price could be driven down to match the worst depegged underlying token, though the judge rated this medium because a depeg event is considered unlikely and user assets are not directly at risk.

What the attacker needed

An accepted underlying token depegs; enough liquidity to trade the token; capital to deposit as collateral

The fix

The repay function should be changed so debt is reduced by market-buying alToken with the underlying token and burning it, rather than crediting it at a fixed ratio.

How it was found

  1. Deposit collateral and mint alToken against it.
  2. Buy the depegged underlying token on the market with the minted alToken.
  3. Repay the debt using the depegged token.
  4. Withdraw the collateral.
  5. Sell the remaining alToken for profit, repeating until the alToken price matches the depegged token.

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.

A stablecoin is a token meant to stay worth about one dollar, but sometimes it slips below that (a 'depeg'). This protocol let people pay back a debt using such a token as if it were still worth a full dollar. So someone could buy the cheap token, use it to clear a debt at full value, take their collateral back and keep the difference, which drags the protocol's own token price down.

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 WatchPug

View all

197 more disclosed reports, best first.

More from Alchemix 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.