The _createIncreasePosition
function in PerpetualVault.sol lacks proper position size validation before interacting with GMX market. When creating increase position orders, the contract calculates sizeDelta without validating against market conditions or GMX's open interest limits. If GMX rejects the order due to insufficient liquidity or exceeded limits, the transaction still costs fees while the position fails to execute properly, leading to partial fund loss.es.
Key issues:
No validation against GMX's openInterest limits
No check against market liquidity
Position size calculated without considering market depth
Partial order execution with full fees charged
User funds locked in failed position increases
Degraded position management efficiency
Extra gas costs from failed operations
The Proof of Concept demonstrates how the lack of position size validation can lead to fund loss. It executes the following steps:
A user deposits the maximum allowed amount (100k USDC)
The system attempts to open a 3x leveraged position without validation
When market conditions are unfavorable (simulated through GMX mock)
The position fails but fees are still charged
The system gets stuck in an unrecoverable state with user funds locked
The test proves that without proper validation, user funds can be partially lost while also leaving the system in a locked state requiring manual intervention.
The PoC demonstrates how a large position increase can lead to system failure and locked funds when market conditions in GMX are unfavorable. The key demonstration is that the vault doesn't validate position sizes against market conditions before attempting to create orders.
Manual code review
Foundry testing framework
Static analysis
Key changes:
Added position size validation
Check against GMX market limits
Validate before transferring funds
Added error handling for size limits
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.
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.
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.