All vulnerabilities
HIGHWeb3

WEB3-TXORIGIN-PHISHING

Web3 · Ethereum · Solidity access control (tx.origin)

Summary

Authorization through tx.origin (SWC-115) is a contract that gates privileged functions with require(tx.origin == owner) instead of msg.sender. In the EVM, tx.origin is always the externally-owned account that signed the outermost transaction, while msg.sender is the immediate caller, which may be a contract. An attacker deploys a malicious intermediary contract and socially engineers the privileged owner into calling it (for example a fake airdrop or withdrawal); when that contract calls the vulnerable function, msg.sender is the attacker contract but tx.origin is still the owner's address, so the tx.origin check passes and the attacker executes owner-only logic such as transferring funds. The flaw is the use of the transaction origin rather than the direct caller for authentication, which collapses the trust boundary between the EOA and any contract it happens to invoke during a call chain. It is a textbook class documented since Ethereum's early years and flagged by every major static analyzer.

How to avoid it in your code

  • Authenticate with msg.sender, never tx.origin, for all access control.
  • Reserve tx.origin only to assert msg.sender == tx.origin (block contract callers) when that is the intent.
  • Use OpenZeppelin Ownable/AccessControl, which key on msg.sender.
  • Add static analysis (Slither, Mythril) gates that reject tx.origin in authentication paths.
  • Treat any contract call as untrusted; do not assume the human signer authorized the inner call.

References

Related vulnerabilities

All Web3 →