Closed sherlock-admin closed 1 year ago
While such a sanity check would be nice, the previousImplentation functionality and checks are optional. Admin is anyway generally trusted with parameters. Considering as a valid low.
Changing these parameters won't result in an instant liquidation - the vault should correctly handle deleveraging and reducing collateral without risking liquidation. If this is not the case, we would consider this a valid bug but there are no details in this report which show why a liquidation would happen
BLACK-PANDA-REACH
medium
Balanced Vault Upgrade can trigger a mass liquidation event
Summary
maxCollateral
ortargetLeverage
can be changed to lower values than that of previous values during upgrade, which will trigger liquidation events whennew targetLeverage < old targetLeverage
ORnew maxCollateral < old maxCollateral
Vulnerability Detail
https://github.com/sherlock-audit/2023-05-perennial/blob/0f73469508a4cd3d90b382eac2112f012a5a9852/perennial-mono/packages/perennial-vaults/contracts/balanced/BalancedVaultDefinition.sol#L86-L88
When upgrading vault from previous implementation to new one, it should have
previousImplementation_.maxCollateral <= maxCollateral_
andpreviousImplementation_.targetLeverage <= targetLeverage_
.Although, there is no check like this while upgrading, so new contract could have smaller values than what previous implementation had. As a result, it will make all the already opened positions which was leveraging
previousImplementation_.targetLeverage
, to get liquidated as after upgrade :new targetLeverage < prevImpl.targetLeverage
.Reducing the
maxCollateral
parameter means that the upgraded vault will have a lower limit on the total amount of collateral it can hold. If the existing positions in the vault exceed this new limit, it can result in insufficient collateral capacity to support those positions. This can lead to liquidation events causing financial losses for the vault users.As can be seen below, in constructor, if
long
andshort
from the previous markets are checked, we suggest to checkmaxCollateral
andtargetLeverage
also while upgrading.https://github.com/sherlock-audit/2023-05-perennial/blob/0f73469508a4cd3d90b382eac2112f012a5a9852/perennial-mono/packages/perennial-vaults/contracts/balanced/BalancedVaultDefinition.sol#L127-L132
Impact
Upgrade can trigger a mass liquidation event if upgraded with a lower
maxCollateral
ortargetLeverage
. Thus causing financial losses for the vault users.Code Snippet
https://github.com/sherlock-audit/2023-05-perennial/blob/0f73469508a4cd3d90b382eac2112f012a5a9852/perennial-mono/packages/perennial-vaults/contracts/balanced/BalancedVaultDefinition.sol#L86-L88
Tool used
Manual Review
Recommendation
We recommend to have a check while upgrading in constructor to make sure new
maxCollateral
ortargetLeverage
is not lower than previous one.