Crypto winter
English

Why tx.origin is unsafe for authorization

The transaction origin persists through intermediate contract calls. It does not show who directly invoked a privileged function.

Risk assessment

The transaction origin persists through intermediate contract calls. It does not show who directly invoked a privileged function.

Mitigation

Use msg.sender with explicit role checks or a reviewed forwarding context. Treat meta-transactions as a separate trust boundary.

Solidity mitigation excerpt

require(hasRole(OPERATOR_ROLE, msg.sender), Unauthorized());

Foundry · Regression check

Assert an unprivileged direct caller is rejected even when a local test sets the transaction origin to a privileged address.

Mitigation

Related topics

What should I verify first?

Assert an unprivileged direct caller is rejected even when a local test sets the transaction origin to a privileged address.

Primary reference