Unable to remove liquidity in Recovery Mode
The UniswapHandler contract, intended to allow liquidity removal during recovery mode, sends the removed liquidity directly to the caller. If the caller is not whitelisted, the transfer reverts, making it impossible for regular users to withdraw their funds.
Submitted by gzeon
According to https://github.com/code-423n4/2021-11-malt#high-level-overview-of-the-malt-protocol
When the Malt price TWAP drops below a specified threshold (eg 2% below peg) then the protocol will revert any transaction that tries to remove Malt from the AMM pool (ie buying Malt or removing liquidity). Users wanting to remove liquidity can still do so via the UniswapHandler contract that is whitelisted in recovery mode.
However, in https://github.com/code-423n4/2021-11-malt/blob/c3a204a2c0f7c653c6c2dda9f4563fd1dc1cecf3/src/contracts/DexHandlers/UniswapHandler.sol#L236 liquidity removed is directly sent to msg.sender, which would revert if it is not whitelisted https://github.com/code-423n4/2021-11-malt/blob/c3a204a2c0f7c653c6c2dda9f4563fd1dc1cecf3/src/contracts/PoolTransferVerification.sol#L53
Recommended Mitigation Steps
Liquidity should be removed to UniswapHandler contract, then the proceed is sent to msg.sender
Alex the Entreprenerd (judge) commented:
I believe this finding to be correct, because of the whitelisting on
verifyTransfer, during recovery mode the removal of liquidity from UniSwapV2Pair will perform safeTransfers: https://github.com/Uniswap/v2-core/blob/4dd59067c76dea4a0e8e4bfdda41877a6b16dedc/contracts/UniswapV2Pair.sol#L148This means that the
_beforeTokenTransferwill be called which eventually will callverifyTransferwhich, if the price is below peg will revert.Transfering the funds to the whitelisted contract should avoid this issue.
I’d like to remind the sponsor that anyone could deploy similar swapping contracts (or different ones such as curve), so if a person is motivate enough, all the whitelisting could technically be sidestepped.
That said, given the condition of LPing on Uniswap, the check and the current system would make it impossible to withdraw funds.
Because this does indeed compromises the availability of funds (effectively requiring the admin to unstock them manually via Whitelisting each user), I agree with High Severity
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
Impact
Users cannot remove liquidity during recovery mode, effectively locking their funds until an admin manually whitelists each user.
What the attacker needed
Recovery mode active (price below peg); user is not whitelisted
The fix
Liquidity should be removed to the UniswapHandler contract first, and then the proceeds sent to the user.
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 DeFi protocol, when the token price drops, normal withdrawals are blocked to prevent panic. A special contract was supposed to let users withdraw anyway, but it sends the funds straight to the user's address. The system then checks if that address is allowed to receive funds; if not, the whole withdrawal fails, locking users out.
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.