Alchemix Missing Solvency Check Bug Fix Review
The liquidation function in Alchemix's smart contract lacked a solvency check after unwrapping collateral, allowing a user to sandwich their own liquidation with a zero minimum output and leave the position undercollateralized. An attacker with significant capital could repeatedly exploit this to mint unbacked alETH, potentially creating over 7k alETH in two hours.
immunefi.com
Published on immunefi.com
On September 28, 2023, the security researcher @KoiushSec submitted a critical vulnerability to Alchemix via Immunefi, which consisted of missing solvency checks at liquidation. At the time of the submission, the vulnerability would have allowed an attacker with significant upfront capital to create over 7k of…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the liquidation function did not verify that the account remained sufficiently collateralized after unwrapping the yield tokens, allowing a user to manipulate the swap and leave bad debt.
Impact
An attacker with significant upfront capital could repeatedly exploit this to mint unbacked alETH, potentially creating over 7k alETH in two hours, but the attack requires substantial capital and cannot be performed with a flash loan.
What the attacker needed
Significant upfront capital; whitelisted address to call liquidate; ability to sandwich transactions
The fix
The fix added a call to _validate in the liquidate function to ensure the position is not undercollateralized after unwrapping.
How it was found
- Deposit 100 stETH into Alchemix and mint 50 alETH against it.
- Call the liquidate function with minimumAmountOut set to 0.
- The unwrap function swaps stETH for underlying asset but is sandwiched by the user, returning near-zero assets.
- The liquidation completes without a solvency check, leaving the debt unpaid and collateral insufficient.
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 write-up has not been written yet. The Original tab links to the source.
In a lending protocol, you deposit collateral and borrow less than its value. Normally, if you borrow too much, the protocol can sell your collateral to repay the debt. Here, the protocol allowed a user to sell their own collateral at a manipulated low price, leaving the debt unpaid and the collateral insufficient. This meant the attacker could create tokens that were not backed by enough assets.
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.