DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Invalid

Insufficient Access Control in setVaultState Enabling State Manipulation

Summary

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.

Vulnerability Details

  • The setVaultState function permits the owner to arbitrarily set key state variables:

    solidity

    function setVaultState(
    FLOW _flow,
    uint256 _flowData,
    bool _beenLong,
    bytes32 _curPositionKey,
    bool _positionIsClosed,
    bool _isLock,
    Action memory _nextAction
    ) external onlyOwner {
    flow = _flow;
    flowData = _flowData;
    beenLong = _beenLong;
    curPositionKey = _curPositionKey;
    positionIsClosed = _positionIsClosed;
    _gmxLock = _isLock;
    nextAction = _nextAction;
    }
  • 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.

Impact

  • 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.

Tools Used

  • Manual code review

Recommendations

Add validation logic to setVaultState to ensure state consistency

Updates

Lead Judging Commences

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Admin is trusted / Malicious keepers

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."

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Admin is trusted / Malicious keepers

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."

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!