Skip to content

tx.origin Used for Authentication

SAFE-0007 Access Control Checked automatically by the scanner
1

What goes wrong

Authorization checks msg.sender against tx.origin or uses tx.origin directly. A malicious intermediate contract the victim interacts with can call the target on the victim's behalf, passing the tx.origin check (phishing).

2

How to fix it

the pattern that is safe
function withdraw() external {
    require(msg.sender == owner, "not owner");
    payable(owner).transfer(address(this).balance);
}
SWC-115. Never authenticate with tx.origin.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0007 among them. Paste an address or the source itself — a small per-scan fee, shown before you sign, or unlimited on any plan.

Run the scanner See how it is attacked Read the docs