Closed rcstanciu closed 2 years ago
The ONLY_VAULT_DELEVERAGE flag would only be set when the calling vault's code is known and audited. It would be irresponsible to allow the vault to set an arbitrary liquidator address but that cannot be known without looking at the listed vault code itself.
I would consider this to be invalid since it is a hypothetical attack vector without a compromised vault that uses this flag.
Arbitrary-Execution
high
When
ONLY_VAULT_DELEVERAGE
is enabled a vault can force an arbitrary address to liquidate an unhealthy vault accountSummary
When
ONLY_VAULT_DELEVERAGE
is enabled a vault can force an arbitrary address to liquidate an unhealthy vault accountVulnerability Detail
When the
ONLY_VAULT_DELEVERAGE
flag is set, only the vault address itself can calldeleverageAccount
inVaultAccountAction.sol
. This is enforced via the_authenticateDeleverage
function:However, inside the
if
block when theONLY_VAULT_DELEVERAGE
flag is set, therequire
statement only checks thatmsg.sender == vault
. This check is different from the other check in theelse
block as it does not check that the passed-inliquidator
address is also the vault address. This means the vault address can supply any address as the liquidator, which is ultimately the address that has to pay the token amount to liquidate an unhealthy vault account. As long as the unwilling liquidator meets the following conditions it can be forced to liquidate accounts by the vault:Impact
A vault can force any address to liquidate an unhealthy vault account so long as the above conditions are met, even if the liquidation would be unprofitable for the liquidator.
Code Snippet
https://github.com/notional-finance/contracts-v2/blob/cf05d8e3e4e4feb0b0cef2c3f188c91cdaac38e0/contracts/external/actions/VaultAccountAction.sol#L343-L348
PoC (add to
tests/stateful/vaults/test_vault_deleverage.py
):Tool used
Manual Review
Recommendation
Consider adding a check to
_authenticateDeleverage
to ensure that when theONLY_VAULT_DELEVERAGE
flag is set the vault account can only set the liquidator to be itself or its owner address.