Skip to content
Business logic Audit finding Intermediate

Transaction can fail due to batchId collision

The smart wallet uses a batchId-based nonce system where batchId 0 is reserved for EntryPoint transactions, but execTransaction does not prevent callers from using batchId 0. An attacker could call execTransaction with batchId 0 to increment the nonce, causing subsequent EntryPoint transactions to fail.

0xdeadbeef0x Follow with romand

Originally disclosed on Code4rena

Submitted by 0xdeadbeef0x, also found by romand

The protocol supports 2D nonces through a batchId mechanism. Due to different ways to execute transaction on the wallet there could be a collision between batchIds being used.

This can result in unexpected failing of transactions

Proof of Concept

There are two main ways to execute transaction from the smart wallet

  1. Via EntryPoint - calls execFromEntryPoint/execute
  2. Via execTransaction

SmartAccount has locked the batchId #0 to be used by the EntryPoint. When an EntryPoint calls validateUserOp before execution, the hardcoded nonce of batchId #0 will be incremented and validated, contracts/smart-contract-wallet/SmartAccount.sol#L501

    // @notice Nonce space is locked to 0 for AA transactions
    // userOp could have batchId as well
    function _validateAndUpdateNonce(UserOperation calldata userOp) internal override {
        require(nonces[0]++ == userOp.nonce, "account: invalid nonce");
    }

Calls to execTransaction are more immediate and are likely to be executed before a UserOp through EntryPoint. There is no limitation in execTransaction to use batchId #0 although it should be called only by EntryPoint.

If there is a call to execTransaction with batchId set to 0. It will increment the nonce and EntryPoint transactions will revert. contracts/smart-contract-wallet/SmartAccount.sol#L216

    function execTransaction(
        Transaction memory _tx,
        uint256 batchId,
        FeeRefund memory refundInfo,
        bytes memory signatures
    ) public payable virtual override returns (bool success) {
-------
            nonces[batchId]++;
-------
        }
    }

Tools Used

VS Code

Recommended Mitigation Steps

Add a requirement that batchId is not 0 in execTransaction:

require(batchId != 0, "batchId 0 is used only by EntryPoint")

livingrockrises (Biconomy) confirmed


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

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 execTransaction function lacks a check to prevent using the reserved batchId 0, allowing the nonce for that lane to be incremented outside the EntryPoint flow.

Impact

EntryPoint transactions could fail unexpectedly, potentially causing a denial of service for the wallet's normal operation.

What the attacker needed

Ability to call execTransaction on the wallet

The fix

The fix should add a requirement in execTransaction that batchId is not 0.

How it was found

  1. Call execTransaction with batchId set to 0.
  2. This increments the nonce for batchId 0.
  3. Subsequent EntryPoint transactions using batchId 0 revert due to nonce mismatch.

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 wallet uses a counter (nonce) to keep track of transactions and prevent replay. Here, the counter is split into separate 'lanes' identified by a batchId, and lane 0 is meant only for transactions coming through the official EntryPoint. Because another function, execTransaction, does not block lane 0, someone can advance that lane's counter, making the wallet reject later legitimate EntryPoint transactions.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by 0xdeadbeef0x

View all

15 more disclosed reports, best first.

More from Biconomy - Smart Contract Wallet contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.