Skip to content
Access control Audit finding Intermediate

Tx.origin Usage in Group Management Contract Allows Phishing Attack for Unauthorized Actions

The group management contract used tx.origin to check ownership, so a malicious contract could call lock, unlock or membership functions on behalf of the owner. An attacker could therefore perform unauthorised actions and take control of group management.

cheems Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#37577 [BC-Insight] `tx.origin` Usage in Group Management Contract Allows Phishing Attack for Unauthorized Actions

Submitted on Dec 9th 2024 at 16:37:44 UTC by @cheems for Attackathon | Ethereum Protocol

Description

Brief/Intro

A critical vulnerability exists in the on-chain group management contract, introduced in PR #1288, where tx.origin was used to verify the contract owner. This allows a malicious contract to impersonate the owner and bypass ownership checks, enabling unauthorized users to lock/unlock the contract or modify group membership. The issue arises from the addition of tx.origin as a check for ownership, which was initially introduced as part of removing the enclave key and ensuring only the creator could update the contract.

Vulnerability Details

In this PR (https://github.com/hyperledger/besu/pull/1288), the intention was to ensure that only the creator's account could add/remove members and update the management contract. However, using tx.origin to validate ownership exposes the contract to phishing attacks, where a malicious contract can call the vulnerable contract on behalf of the attacker. Since tx.origin refers to the original transaction sender, the attacker only needs to initiate the call (not execute the exploit directly), allowing them to bypass the ownership checks.

Impact Details

Provide a detailed breakdown of possible losses from an exploit, especially if there are funds at risk. This illustrates the severity of the vulnerability, but it also provides the best possible case for you to be paid the correct amount. Make sure the selected impact is within the program’s list of in-scope impacts and matches the impact you selected.

References

Add any relevant links to documentation or code

Link to Proof of Concept

https://gist.github.com/SamruddhiNavale/100b48157a7101d53bee9056b2a7dbb7

Proof of Concept

Proof of Concept

pragma solidity ^0.8.0;

interface IVulnerableContract {
    function lock() external;
    function unlock() external;
}

contract MaliciousContract {
    IVulnerableContract public vulnerableContract;

    constructor(address _vulnerableContract) {
        vulnerableContract = IVulnerableContract(_vulnerableContract);
    }

    function attackLock() public {
        vulnerableContract.lock(); // Attack via tx.origin impersonation
    }

    function attackUnlock() public {
        vulnerableContract.unlock(); // Attack via tx.origin impersonation
    }
}

Steps to Reproduce:

  1. Deploy the Vulnerable Contract on a local test network.
  2. Deploy the Malicious Contract, passing the vulnerable contract address.
  3. Call attackLock() or attackUnlock() from the malicious contract.
  4. Verify the contract state is locked/unlocked by the attacker.

Expected Result:

The contract should only allow the actual owner to lock/unlock or modify its state.

Actual Result:

The malicious contract can lock/unlock or modify the contract state due to the tx.origin vulnerability.


Impact:

This vulnerability allows attackers to impersonate the contract owner and perform unauthorized actions, bypassing the intended ownership checks. It can lead to unauthorized updates to the contract and loss of control over group management.


Mitigation Recommendations:

  1. Avoid Using tx.origin for ownership checks.
  2. Use msg.sender for proper access control.
  3. Implement proper access control mechanisms like onlyOwner.

Conclusion:

This vulnerability, introduced in PR #1288, exposes the contract to phishing attacks by using tx.origin. The malicious contract only needs to initiate the call, not execute the exploit directly, to bypass ownership checks.

The original report as published on Immunefi, by cheems. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The contract used tx.origin instead of msg.sender to verify that the caller was the owner, so any contract called by the owner could act with owner privileges.

Impact

An attacker could impersonate the contract owner and lock or unlock the contract or change group membership, leading to loss of control over group management.

What the attacker needed

Owner interacts with a malicious contract; attacker can deploy a contract

The fix

The contract should stop using tx.origin for ownership checks and use msg.sender with a proper onlyOwner access control modifier instead.

How it was found

  1. Deploy the vulnerable contract on a local test network.
  2. Deploy a malicious contract that stores the vulnerable contract's address.
  3. Call the malicious contract's attack function, which calls lock or unlock on the vulnerable contract.
  4. Check that the vulnerable contract's state has changed even though the attacker is not the owner.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract is a program on a blockchain. tx.origin is a special value that tells a contract who started the whole transaction, not who is calling it right now. If a contract trusts tx.origin for permission checks, any other contract that the real owner interacts with can pretend to be the owner and call protected functions.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More from Ethereum Protocol

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.