Skip to content
Access control Audit finding Advanced

onlyEOAEx modifier that ensures call is from EOA might not hold true in the future

The onlyEOAEx modifier relies on tx.origin to ensure the caller is an externally owned account (EOA), but EIP 3074 would allow a smart contract to act on behalf of an EOA, so the check may no longer hold. An attacker could then bypass the EOA-only restriction and make calls from a contract.

koxuan Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-02-blueberry-judging/issues/21

Found by

koxuan

Summary

modifier onlyEOAEx is used to ensure calls are only made from EOA. However, EIP 3074 suggests that using onlyEOAEx modifier to ensure calls are only from EOA might not hold true.

Vulnerability Detail

For onlyEOAEx, tx.origin is used to ensure that the caller is from an EOA and not a smart contract.

Solidity
    modifier onlyEOAEx() {
        if (!allowContractCalls && !whitelistedContracts[msg.sender]) {
            if (msg.sender != tx.origin) revert NOT_EOA(msg.sender);
        }
        _;
    }

However, according to EIP 3074,

This EIP introduces two EVM instructions AUTH and AUTHCALL. The first sets a context variable authorized based on an ECDSA signature. The second sends a call as the authorized account. This essentially delegates control of the externally owned account (EOA) to a smart contract.

Therefore, using tx.origin to ensure msg.sender is an EOA will not hold true in the event EIP 3074 goes through.

Impact

Using modifier onlyEOAEx to ensure calls are made only from EOA will not hold true in the event EIP 3074 goes through.

Code Snippet

BlueBerryBank.sol#L54-L59

Tool used

Manual Review

Recommendation

Recommend using OpenZepellin's isContract function (https://docs.openzeppelin.com/contracts/2.x/api/utils#Address-isContract-address-). Note that there are edge cases like contract in constructor that can bypass this and hence caution is required when using this.

Solidity
    modifier onlyEOAEx() {
        if (!allowContractCalls && !whitelistedContracts[msg.sender]) {
            if (isContract(msg.sender)) revert NOT_EOA(msg.sender);
        }
        _;
    }

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

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

Likely the modifier uses tx.origin as a proxy for 'is an EOA', which is not a reliable guarantee once EIP 3074 enables a contract to act as an EOA.

Impact

If EIP 3074 is adopted, the EOA-only restriction could be bypassed, allowing a contract to make calls that were intended to be restricted to EOAs.

What the attacker needed

EIP 3074 must be adopted

The fix

The recommendation is to replace the tx.origin check with OpenZeppelin's isContract function, while noting edge cases such as a contract in its constructor.

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 uses a check to make sure only ordinary user accounts (not other contracts) can call certain functions. The check assumes that if the caller's address equals the transaction origin, the caller must be an ordinary account. A proposed Ethereum upgrade (EIP 3074) would let a contract act on behalf of an ordinary account, so that assumption could become false and the check could be bypassed.

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 by koxuan

View all

7 more disclosed reports, best first.

More from Blueberry Update #3

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.