The setPerpVault function in the GmxProxy contract uses tx.origin to check the caller's ownership.
This causes the contract to incorrectly reject transactions where the owner calls the function through an intermediary contract.
Severity: High
Likelihood: Medium to High
Impact: High
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/main/contracts/GmxProxy.sol#L346-L357
The function setPerpVault uses tx.origin to verify the caller’s ownership.
tx.origin refers to the original sender of the transaction, which could cause mismatches if the function is called via an intermediary contract.
This makes it impossible for the owner to call the function through intermediary contracts, even though they are the original sender.
An attacker can exploit this by manipulating the call chain to bypass the ownership check.
Using tx.origin instead of msg.sender causes incorrect ownership checks and prevents the owner from interacting through intermediaries.
This could be exploited by attackers to bypass ownership control, potentially manipulating contract state or funds.
It compromises the security of the contract by allowing unauthorized access.
Likelihood: Medium to High
tx.origin misuse is a common vulnerability in Solidity.
If the contract interacts with other contracts (e.g., proxies), attackers can easily exploit this issue by crafting transactions through intermediaries.
The test cases demonstrated this issue, showing that even the owner was prevented from executing the function through an intermediary contract.
Test output showing the failure of the contract when the owner calls setPerpVault through vm.startPrank:
Manual
Fix: Replace tx.origin with msg.sender in the setPerpVault function.
Fixed Code Snippet:
By using msg.sender, the contract will correctly verify the immediate caller’s identity, even when intermediaries are involved.
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.