Submitted by LuarSec, also found by Tigerfrake, Kaysoft, Takarez, 0xhere2learn, ayden, SBSecurity, erictee, DPS, Joshuajee, dyoff, 0xMilenov, forgebyola, pkqs90, gumgumzum, shaflow2, SpicyMeatball, zhaojohnson, MSaptarshi, MrCrowNFT, jolah1, WinSec, EaglesSecurity, lydia_m_t, and chista0x
https://github.com/code-423n4/2024-05-predy/blob/a9246db5f874a91fb71c296aac6a66902289306a/src/PredyPool.sol#L289https://github.com/code-423n4/2024-05-predy/blob/a9246db5f874a91fb71c296aac6a66902289306a/src/libraries/logic/LiquidationLogic.sol#L99
Vault owners can set vault.recipient via the external PredyPool.updateRecepient function to set the address that will receive the vaults remaining positive margin when the vaults position is liquidated, denominated in the quote token:
A malicious vault owner can set vault.recipient to a blacklisted/prohibited address for the quote token, such as 0x0E6b8E34dC115a2848F585851AF23D99D09b8463, which is blacklisted in Arbitrums USDC contract. If the remaining margin is positive, the safeTransfer operation on line 97 in LiquidationLogic.liquidate may revert, as is the case with USDC:
As a new vault can be created when making a trade, any malicious user can maintain their own vault for a trade. The owner of a vault at risk of liquidation with a positive vault.margin can effectively switch off liquidations at will if the quote token reverts when sending tokens to blacklisted addresses, preventing the entire liquidation operation from succeeding.
This results in unsafe unliquidatable vault positions remaining in the protocol, putting both the protocol and its users at risk. This can be abused in several ways:
The following Forge test case test_audit_LiquidateBlacklist and modifications can be added to test/pool/ExecLiquidationCall.t.sol and test/mocks/MockERC20.sol to simulate a liquidator being prevented from liquidating the unsafe position.
Note that in the provided test setup, closeRatio needed to be 1e18 to get remainingMargin over zero in line 92 of LiquidationLogic; however, it is believed that the required ratio range for a positive remainingMargin will be wider under real market conditions.
test/pool/ExecLiquidationCall.t.sol:
test/mocks/MockERC20.sol:
In the repos base directory, run the following command to execute the test. Observe that the output includes the Blacklistable error message:
Foundry, VS Code
Blacklisted addresses can be checked against supporting quote tokens before they are set to vault.recipient in PredyPool.updateRecepient. In the case of USDC, this would involve calling the USDC contracts isBlacklisted method for supplied addresses. Ensure that this does introduce any callback/reentrancy issues by also making PredyPool.updateRecepient nonreentrant.
To prevent abuse of this issue via frontrunning, require that a vaults position is healthy in PredyPool.updateRecepient before vault.recipient can be changed, so long as this does not interfere with any calls to PredyPool.updateRecepient made by existing market contracts.
Token-Transfer
0xsomeone (judge) decreased severity to Medium and commented:
syuhei176 (Predy) confirmed
