Vulnerable Contract: GmxProxy
Function Affected: afterOrderCancellation
Issue: An external call is made to perpVault
before the state variable queue
is cleared, creating a reentrancy vulnerability.
Potential Impact: Attacker can re-enter the contract and manipulate orders before state resets.
Severity: High
External Call Before State Change:
The function makes an external call to perpVault
before clearing queue
.
If perpVault
is controlled by an attacker, they can execute a reentrant call before queue
is deleted.
Shared State Across Functions (Cross-Function Reentrancy):
queue
is accessed in multiple functions:
afterOrderCancellation()
afterOrderExecution()
cancelOrder()
createOrder()
A reentrant call could manipulate queue
before it resets, leading to unauthorized actions.
Attacker Deploys Malicious Vault Contract:
A custom perpVault
contract is deployed that calls back into GmxProxy
before queue
is deleted.
Attacker Calls afterOrderCancellation()
:
This triggers the external call to perpVault
.
Malicious Contract Executes Reentrant Call:
Before queue
is deleted, the attacker calls createOrder()
or cancelOrder()
, leveraging outdated queue
data.
This PoC exploit demonstrates how an attacker can re-enter the GmxProxy
contract before queue
is deleted.
Vs code
Ensure queue
is deleted before the external call to perpVault
;
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.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
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.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
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.