Open c4-bot-2 opened 5 months ago
alex-ppg marked the issue as selected for report
alex-ppg marked the issue as satisfactory
The submission and its duplicates describe a way that can prevent a user's position from being liquidated by setting a receiver that has been blacklisted in one of the tokens officially supported by the system per the contest's README
.
This vulnerability is significant, as it would prevent any liquidation that results in a positive margin from being carried out given that a user can change the vault's recipient at will to a blacklisted user. I believe a medium-risk rating is appropriate given that the Denial-of-Service is impermanent and liquidations can be performed at a zero or negative margin, however, I believe it is an interesting vulnerability that properly applies to the tokens officially supported in the system.
To note, any submission that does not identify the way liquidations are affected will be penalized by 25% (i.e. rewarded 75%).
alex-ppg changed the severity to 2 (Med Risk)
Lines of code
ttps://github.com/code-423n4/2024-05-predy/blob/a9246db5f874a91fb71c296aac6a66902289306a/src/PredyPool.sol#L289 https://github.com/code-423n4/2024-05-predy/blob/a9246db5f874a91fb71c296aac6a66902289306a/src/libraries/logic/LiquidationLogic.sol#L99
Vulnerability details
Impact
Vault owners can set
vault.recipient
via the externalPredyPool.updateRecepient
function to set the address that will receive the vault's remaining positive margin when the vault's 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 as0x0E6b8E34dC115a2848F585851AF23D99D09b8463
which is blacklisted in Arbitrum's USDC contract. If the remaining margin is positive, thesafeTransfer
operation on line 97 inLiquidationLogic.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:
PredyPool.updateRecepient
to setvault.recipient
to a blacklisted quote token address, optionally reverting the change after the liquidation attempt fails.Proof of Concept
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 be1e18
to getremainingMargin
over zero in line 92 of LiquidationLogic, however it is believed that the required ratio range for a positiveremainingMargin
will be wider under real market conditions.test/pool/ExecLiquidationCall.t.sol
test/mocks/MockERC20.sol
Blacklistable
error message:Tools Used
Foundry, VS Code
Recommended Mitigation Steps
vault.recipient
inPredyPool.updateRecepient
. In the case of USDC, this would involve calling the USDC contract'sisBlacklisted
method for supplied addresses. Ensure that this does introduce any callback/reentrancy issues by also makingPredyPool.updateRecepient
nonreentrant.safeTransfer
on line 97 inLiquidationLogic.liquidate
.PredyPool.updateRecepient
beforevault.recipient
can be changed, so long as this does not interfere with any calls toPredyPool.updateRecepient
made by existing market contracts.Assessed type
Token-Transfer