The setVaultState function in the PerpetualVault contract allows the owner to modify critical state variables (e.g., flow, flowData, beenLong, curPositionKey, positionIsClosed, _gmxLock, nextAction) without sufficient validation. This lack of safeguards enables a malicious or careless owner to set invalid states, potentially causing fund misallocation, unauthorized position manipulation, or vault insolvency.
The setVaultState function permits the owner to arbitrarily set key state variables:
solidity
There are no checks to ensure state consistency, such as:
Ensuring curPositionKey != 0 if positionIsClosed = false.
Validating that _flow and _nextAction.selector align with the contract’s current state or protocol invariants.
Preventing invalid combinations (e.g., setting flow = FLOW.DEPOSIT while positionIsClosed = true).
This allows the owner to bypass normal flow logic, potentially enabling unauthorized position changes or fund misallocation.
Fund Misallocation: An owner could manipulate state to overpay or underpay users, withdraw funds improperly, or create invalid positions, leading to financial losses.
Vault Insolvency: Incorrect state settings could trigger liquidations, fail withdrawals, or disrupt keeper operations, risking the vault’s solvency.
Centralization Risk: Excessive owner control without safeguards increases centralization risks, undermining the protocol’s decentralization claims.
Manual code review
Add validation logic to setVaultState to ensure state consistency
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point. Keepers are added by the admin, there is no "malicious keeper" and if there is a problem in those keepers, that's out of scope. ReadMe and known issues states: " * System relies heavily on keeper for executing trades * Single keeper point of failure if not properly distributed * Malicious keeper could potentially front-run or delay transactions * Assume that Keeper will always have enough gas to execute transactions. There is a pay execution fee function, but the assumption should be that there's more than enough gas to cover transaction failures, retries, etc * There are two spot swap functionalies: (1) using GMX swap and (2) using Paraswap. We can assume that any swap failure will be retried until success. " " * Heavy dependency on GMX protocol functioning correctly * Owner can update GMX-related addresses * Changes in GMX protocol could impact system operations * We can assume that the GMX keeper won't misbehave, delay, or go offline. " "Issues related to GMX Keepers being DOS'd or losing functionality would be considered invalid."
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point. Keepers are added by the admin, there is no "malicious keeper" and if there is a problem in those keepers, that's out of scope. ReadMe and known issues states: " * System relies heavily on keeper for executing trades * Single keeper point of failure if not properly distributed * Malicious keeper could potentially front-run or delay transactions * Assume that Keeper will always have enough gas to execute transactions. There is a pay execution fee function, but the assumption should be that there's more than enough gas to cover transaction failures, retries, etc * There are two spot swap functionalies: (1) using GMX swap and (2) using Paraswap. We can assume that any swap failure will be retried until success. " " * Heavy dependency on GMX protocol functioning correctly * Owner can update GMX-related addresses * Changes in GMX protocol could impact system operations * We can assume that the GMX keeper won't misbehave, delay, or go offline. " "Issues related to GMX Keepers being DOS'd or losing functionality would be considered invalid."
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.