The setPerpVault
function in GmxProxy.sol uses tx.origin
for authorization instead of msg.sender
. This critical vulnerability allows malicious contracts to bypass ownership checks and potentially gain control over vault interactions with GMX.
The function relies on tx.origin
for authorization, which represents the original external account that initiated the transaction, rather than the immediate caller (msg.sender
).
Malicious contracts can trick vault owner into interacting with them
Potential redirection of all GMX interactions
Complete compromise of vault controls
Risk of fund loss through manipulated callbacks
The Proof of Concept demonstrates how an attacker can exploit the tx.origin authentication in GmxProxy to hijack the vault system through a phishing contract:
Setup:
Deploy GmxProxy with legitimate owner
Attacker creates a malicious vault contract
Attacker deploys a phishing contract appearing legitimate to owners
Attack Flow:
The phishing contract includes legitimate-looking functions (e.g., 'claim')
When owner interacts with the phishing contract
The contract secretly calls setPerpVault during execution
Since tx.origin matches owner, the call succeeds
Malicious vault becomes the authorized vault
Impact:
Attacker gains control of vault interactions
All future GMX operations can be intercepted
System security is compromised despite owner's careful setup
The test provides concrete proof that using tx.origin for authentication creates a critical security weakness, allowing attackers to bypass intended access controls through indirect contract interactions.
The PoC demonstrates how a malicious contract can trick the vault owner into unknowingly setting a malicious vault address, potentially compromising the entire system's security.
Manual code review
Foundry testing framework
Static analysis (detecting tx.origin usage)
Replace tx.origin with msg.sender and use OpenZeppelin's onlyOwner modifier:
Lightchaser: Medium-5
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.