Cheerful Taffy Dolphin - Stale Parameter Usage in Rebalance Causes Incorrect Position Sizing and Risk Management Failures #43
Labels
Sponsor Disputed
The sponsor disputed this issue's validity
Cheerful Taffy Dolphin
Medium
Stale Parameter Usage in Rebalance Causes Incorrect Position Sizing and Risk Management Failures
Summary
The Vault contract contains a significant timing vulnerability in its parameter update mechanism that could result in incorrect market positions, financial loss, and state inconsistency. When updating vault parameters (maxDeposit, minDeposit, profitShare), the rebalancing operation executes using outdated parameters before the new values are stored, leading to incorrect position sizing and potential violations of intended risk constraints.
Parameter Update:
https://github.com/sherlock-audit/2025-01-perennial-v2-4-update/blob/main/perennial-v2/packages/vault/contracts/Vault.sol#L241
Context Loading with Old Parameters:
Parameter Usage in Core Operations:
The issue is that rebalancing executes a full market position adjustment using the old parameter values. This means:
maxDeposit
calculation during rebalance uses outdated deposit limits_strategy()
function (which is called by_manage()
during rebalance) bases its allocation decisions on old parametersThis is particularly problematic in scenarios where parameter updates are specifically intended to adjust risk parameters or position limits in response to market conditions.
Impact
The parameter update timing issue creates critical failure modes in the vault's market management. The vault executes rebalancing operations using stale parameter values, which manifests in multiple levels of technical failures:
At the position management level, all market orders during rebalance are sized according to outdated maxDeposit and strategy parameters, leading to incorrect leverage ratios and position sizes that violate the intended new risk parameters. For instance, if maxDeposit is being lowered from 1000 to 500, the rebalance will still execute positions sized for the 1000 limit.
These incorrectly sized positions trigger state inconsistencies where the vault's market exposure directly conflicts with its stored parameters. This forces additional transactions to realign positions, introducing unnecessary gas costs and potential sandwich attack vectors during the corrective operations.
This breaks the vault's risk management guarantees. When parameter updates are made in response to market conditions (e.g., reducing maxDeposit during high volatility), the delay in parameter application means the vault continues to operate at higher risk levels during the rebalance - precisely when risk management is most crucial.
Fix
Modify the
updateParameter
function to handle parameters before rebalancing:Ensure state consistency in
_loadContext
:And add validation in
_updateParameter
:The rebalance will now use the new parameters for all calculations and position adjustments, ensuring proper risk management and position sizing.
The text was updated successfully, but these errors were encountered: