EIPs Explained

EIP-7645 · Stagnant · Core · 2024-03-03

EIP-7645: Alias ORIGIN to SENDER

Proposed making the ORIGIN opcode (tx.origin) return the same value as CALLER (msg.sender), removing a long-discouraged feature that complicates account abstraction and enables phishing.

What problem does it solve?

The EVM has two "who called me?" opcodes:

  • CALLER (0x33, Solidity msg.sender): the immediate caller of the current frame.
  • ORIGIN (0x32, Solidity tx.origin): the EOA that signed the whole transaction, no matter how many contracts sit in between.

Using tx.origin for authorization has been discouraged since 2016. A malicious contract you interact with can call another contract that checks tx.origin == owner, and the check passes. It also clashes with account abstraction. In ERC-4337, tx.origin is the bundler for every bundled user operation, so anything the bundler is authorized for via tx.origin could be hijacked by any of them. Every AA design has to decide what ORIGIN should mean.

EIP-7645 proposes ending the question by aliasing ORIGIN to CALLER.

How it works

  • In every execution context, ORIGIN pushes exactly what CALLER would push: the current frame's sender.
  • Transaction format and validation are unchanged; only the opcode's result changes.
  • In a direct EOA-to-contract call, nothing visibly changes, because origin and sender are already equal. In multi-hop calls (CALL, STATICCALL, DELEGATECALL, CALLCODE), ORIGIN would now equal the immediate caller at every depth.

Sample code

How common patterns would behave:

contract Example {
    // Pattern 1: "only EOAs may call me" (blocks contracts / flash-loan bots)
    function onlyEOA() external view {
        require(tx.origin == msg.sender, "no contracts");
        // Today: fails when called through a contract.
        // Under EIP-7645: tx.origin == msg.sender always holds, so this check stops doing anything.
    }

    // Pattern 2: phishable owner check
    address owner;
    function withdraw() external {
        require(tx.origin == owner);   // vulnerable today
        // Under EIP-7645: behaves like msg.sender == owner, closing the phishing hole.
        payable(msg.sender).transfer(address(this).balance);
    }
}

Things to know

  • Status: Stagnant. It has not been scheduled for any upgrade, and ORIGIN keeps its current meaning on mainnet.
  • It is not fully backwards compatible: contracts that rely on tx.origin != msg.sender, such as "EOA-only" checks, would silently lose that protection. The spec text also contains a contradictory "No backward compatibility issues found" line.
  • The spec suggests going further, outside this EIP, by banning ORIGIN in tooling or at deploy time.
  • Account abstraction for EOAs has since moved forward through EIP-7702, which leaves ORIGIN as is. Under 7702, an EOA with delegated code can make calls from code, so tx.origin == msg.sender is no longer a reliable "not a contract" test either.
  • Earlier AA proposals that the spec cites as running into the same issue: EIP-3074 and EIP-7377.

#evm #opcode #tx-origin #account-abstraction #security

Details

Authors
Cyrus Adkisson (@cyrusadkisson), Eirik Ulversøy (@EirikUlversoy)
Status
Stagnant
Type
Standards Track / Core
Created
2024-03-03

Machine-readable: Markdown · JSON