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

`tx.origin` Vulnerability is found in `setPerpVault` Function in `PerpVault Contract

Description

The function uses tx.origin for owner verification instead of msg.sender. This is dangerous because tx.origin always points to the original address that started the transaction, not the immediate caller of the function.

Impact

Here are 5 key impacts of this tx.origin vulnerability:

  1. Unauthorized Vault Setup: The attacker can set their malicious vault address, which the actual owner didn't approve.

  2. Permanent Lock-in: Since the vault can only be set once (due to require(perpVault == address(0)), if an attacker successfully exploits this, there's no way to change it back.

  3. Potential Fund Theft: If user funds go through this vault system, an attacker's malicious vault could be used to redirect or steal assets.

  4. Market Manipulation: Through the gExchangeRouter.setSavedCallbackContract() call, attackers could manipulate market callbacks for trading operations.

  5. Protocol Trust Breach: Since this affects core infrastructure setup (vault connections), it undermines the entire protocol's trustworthiness and security.

Tools Used

Manual Review

Recommendations

Replace tx.origin with msg.sender:

- require(tx.origin == owner(), "not owner");
+ require(msg.sender == owner(), "not owner");

Consider adding mitigation suggestions beyond just the msg.sender fix: Using OpenZeppelin's Ownable contract.

function setPerpVault(address _perpVault, address market) external onlyOwner {
// ... rest of the function
}

This way, only direct calls from the owner will be allowed, making the function secure against phishing attacks.

Updates

Lead Judging Commences

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

invalid_tx-origin

Lightchaser: Medium-5

Support

FAQs

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