AccountManager: Liquidations not possible when transfer fails
The liquidation function iterates over all assets and attempts to transfer each one; if any single transfer fails, the entire liquidation reverts. An attacker could deliberately cause a transfer to fail (e.g., by getting blacklisted by USDC) to avoid being liquidated.
panprog Follow with csanuragjain, Czar102 and 8 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2022-08-sentiment-judging/tree/main/033-M
Found by
panprog, csanuragjain, Czar102, carrot, PwnPatrol, Lambda, kirk-baird, berndartmueller, rbserver, Chom, __141345__
Summary
When the transfer of one asset fails, liquidations become impossible.
Vulnerability Detail
_liquidate calls sweepTo, which iterates over all assets. When one of those transfers fails, the whole liquidation process therefore fails. There are multiple reasons why a transfer could fail:
1.) Blocked addresses (e.g., USDC)
2.) The balance of the asset is 0, but it is still listed under asset. This can be for instance triggered by performing a 0 value Uniswap swap, in which case it is still added to tokensIn. Another way to trigger is to call deposit with amt = 0 (this is another issue that should be fixed IMO, in practice the assets of an account should not contain any tokens with zero balance)
Some tokens revert for zero value transfers (see https://github.com/d-xo/weird-erc20)
3.) Paused tokens
4.) Upgradeable tokens that changed the implementation.
Impact
See above, an account cannot be liquidated. In certain conditions, this might even be triggerable by the user. For instance, a user could try to get on the USDC blacklist to avoid liquidations.
Code Snippet
https://github.com/sherlock-audit/2022-08-sentiment/blob/main/protocol/src/core/AccountManager.sol#L384 https://github.com/sherlock-audit/2022-08-sentiment/blob/main/protocol/src/core/Account.sol#L166
Tool used
Manual Review
Recommendation
Catch reversions for the transfer and skip this asset (but it could be kept in the assets list to allow retries later on).
Sentiment Team
Fixed as recommended. PR here.
Lead Senior Watson
Confirmed fix.
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 liquidation logic does not handle failed transfers gracefully; it reverts the entire transaction instead of skipping the problematic asset.
Impact
An account cannot be liquidated, and in some cases the user can trigger this condition themselves (e.g., by getting on the USDC blacklist).
What the attacker needed
A position eligible for liquidation; at least one asset that fails to transfer
The fix
The fix was to catch reversions for the transfer and skip the failing asset, while keeping it in the assets list for later retries.
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 a lending protocol, if a borrower's collateral value drops too low, anyone can liquidate them to keep the system solvent. Here, the liquidation code tries to move all of the borrower's assets at once, and if moving just one asset fails (for example, because the token blocks that address), the whole liquidation fails. This means a borrower could intentionally make one asset untransferable to avoid being liquidated.
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.