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.
Submitted by WatchPug
function _normalizeUnderlyingTokensToDebt(address underlyingToken, uint256 amount) internal view returns (uint256) {
return amount * _underlyingTokens[underlyingToken].conversionFactor;
}
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:
- Deposit
100M USDCas collateral and mint75M alUSD(100*0.75); - Market buy
75M USDTwith67.5M alUSD(75*0.9) and repay the debt; - Withdraw the
100M USDCcollateral; - 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 ofalTokendown 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.
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
- Deposit collateral and mint alToken against it.
- Buy the depegged underlying token on the market with the minted alToken.
- Repay the debt using the depegged token.
- Withdraw the collateral.
- 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.