Skip to content
Basis Desk
Security & Hacks · 7 min read Last reviewed November 21, 2026

How Wallet Drainers Bypass Simulators: Counterfactual EVM Exploits

Malicious contracts bypass security simulations by altering blockchain state between dry-run and settlement, using counterfactual factory deployment, and disguising signature permissions.

Editorial oversight: Julian Mercer, Chief Editor
Neutral
How Wallet Drainers Bypass Simulators: Counterfactual EVM Exploits

Key points

  • Simulators evaluate transactions against static historical state, allowing attackers to bypass alerts using conditional state changes.
  • The CREATE2 opcode enables drainers to direct permissions to counterfactual addresses before malicious code is deployed.
  • Disguised Permit2 signatures bypass traditional ERC-20 approval warnings by using authorized off-chain EIP-712 structured data.
  • Attackers encapsulate administrative commands like SetOwner inside multi-call wrappers to mask account takeovers as harmless interactions.

Modern wallet drainers evade preview screens by engineering differences between off-chain transaction simulations and on-chain execution. Security extensions evaluate prospective actions by executing them against a static copy of current network state, but malicious contracts can alter external conditions, deploy dynamic bytecode through CREATE2, or mask permissions behind token standards like Permit2 to produce benign simulation reports before emptying user balances.

Understanding these evasions requires analyzing how client software reads Ethereum Virtual Machine (EVM) data, how decentralized protocols delegate permissions, and how state-dependent execution invalidates client-side security warnings.

The Mechanics of Transaction Simulation

Transaction simulators act as security proxies between user interfaces and network settlement. When an end user connects an EVM-compatible wallet to a decentralized application, the client sends prospective transaction payloads—consisting of a target address, calldata, and authorization signatures—to an RPC node. Instead of broadcasting the transaction to public mempools, the node invokes an execution tracing method, commonly eth_call or an engine-level debug tracer.

The node runs the proposed bytecode within a virtualized, read-only fork of the most recent block state. It calculates state transitions, gas consumption, and emitted event logs. If the dry run reduces a user token balance without returning an expected receipt, security software alerts the user to malicious behavior. If the simulation executes without token transfers, the interface signals that the transaction is safe.

This architecture assumes that the code executed in the fork matches the code executed on-chain, and that external chain conditions remain identical between the preview and final block inclusion. Attackers design payloads specifically to invalidate this assumption.

State-Changing Execution and Pre-Trade Conditions

A basic method for bypassing simulators involves state-dependent branches in a smart contract. An EVM contract can query on-chain variables during execution, such as block numbers, timestamps, public contract states, or balances of intermediary addresses. Malicious contracts use these parameters to present one behavior to simulators and another to validators.

Simulations run inside an isolated snapshot of the current state. Attackers can condition their malicious execution branch on state variables that the simulator cannot replicate ahead of time. For example, a contract may read a specific variable, such as a boolean switch controlled by an operator address, or the balance of a secondary token within an external pool.

During simulation, the switch remains false. The contract executes a harmless operation, such as minting an empty non-fungible token (NFT) or updating an internal registry, returning zero value outflows in the wallet interface. When the victim submits the signed transaction, the attacker submits a coordinated transaction via a private RPC or builder bundle to flip the state variable immediately before the victim payload executes. With the switch turned on, the contract routes into an asset-transfer loop that strips approved tokens from the victim account. The simulation environment, evaluating only the isolated user transaction against historical block state, fails to forecast this coordinated change.

Counterfactual Deployment via CREATE2

More advanced drainers exploit counterfactual contract instantiation, made possible by the EVM opcode CREATE2. Traditional contract creation via CREATE derives target contract addresses deterministically from the deployer account address and its transaction nonce. By contrast, CREATE2 calculates an address from four parameters: a fixed prefix, the deployer address, a salt value, and the cryptographic hash of the contract initialization code (init_code).

Because the deployment address depends on the hash of the initialization code, the target address can receive assets, token approvals, or signatures before any code is deployed to that address. Drainer networks abuse this counterfactual property in coordination with SELFDESTRUCT or ephemeral factory contracts.

In a typical bypass flow, an attacker presents a victim with a transaction targeting an address where no code exists. When a simulator evaluates a call to an empty externally owned account or undeployed contract, the trace completes instantly without state alterations or warnings. However, the attacker crafts the sequence such that a factory contract deploys malicious code to that predetermined address inside the exact same block or bundle, right before executing the user transaction. Once execution completes, the deployed contract drains assets using the authorized signatures, and may terminate its own code state, leaving no trace in naive point-in-time simulations run seconds prior.

Disguised Approvals via Permit2 and Multi-Calls

Wallet simulators traditionally alert users when calldata contains standard ERC-20 approve functions directed at unverified addresses. To evade signature parsing, drainers route malicious authorizations through universal approval routers, primarily Uniswap's Permit2 architecture.

Permit2 standardizes token approvals across applications. Instead of granting approvals to individual exchange routers, users issue a one-time, shared allowance to the canonical Permit2 contract. Subsequent transfers rely on off-chain cryptographic signatures following the EIP-712 standard, which encode parameters like spending amounts, expiration deadlines, and operational nonces.

Drainers exploit this architecture by requesting signatures that look like routine application logins or non-financial verification requests. Because the victim has already granted a general token allowance to the legitimate Permit2 contract on-chain, the transaction simulator does not register an active on-chain approve invocation. Instead, the user signs an off-chain structured hash.

When the attacker submits this signature to Permit2's permitTransferFrom method, the canonical contract verifies the cryptographic parameters and transfers the tokens to an attacker-controlled receiver. Basic wallet simulators that only parse primary smart contract function selectors without recursively validating structured EIP-712 permit schemas present the message as a neutral data signature, failing to warn that the signature grants unilateral control over existing wallet balances. This attack vector often operates alongside broader phishing strategies described in our guide to how crypto wallet drainers operate.

SetOwner and Access-Control Calldata Masking

Another evasive technique targets smart contract wallets and account abstraction implementations by disguising administrative role reassignments as arbitrary contract interactions. Traditional wallets rely on a single private key, whereas smart accounts follow contract logic that delegates spending permissions to verified owners or modules.

Drainers obfuscate calls to functions like setOwner, addOwnerWithThreshold, or custom administrative entry points. Attackers encapsulate these calls inside generic execution functions, such as execute(address to, uint256 value, bytes data). If a security extension monitors only top-level method IDs, it flags the transaction as an opaque interaction with a wallet infrastructure contract rather than an asset transfer.

During simulation, invoking an administrative modification does not directly alter token balances or trigger ERC-20 transfer events. The simulator reports zero asset movement. Once finalized on-chain, the attacker claims co-ownership or updates fallback handler logic, granting persistent control to drain assets asynchronously across subsequent blocks.

Worked Example: Anatomy of an Evaded Permit2 Extraction

To understand how these elements converge, examine a multi-step asset extraction bypassing standard wallet heuristics.

Assume a user holds 50,000 units of an ERC-20 token ($USDC) and previously authorized the canonical Permit2 deployment address (0x000000000022D473030F116dDEE9F6B43aC78BA3) during regular decentralized exchange trading. The user visits a compromised application interface that initiates an asset drain.

  1. The interface prompts the user to sign an off-chain EIP-712 payload. The payload specifies the spender address as an uninitialized contract (0xContractA), the token address, an allowance amount of 50,000 $USDC, an expiration timestamp, and an incremented nonce.
  2. The wallet extension intercepts the message. Because it is a typed data signature rather than a direct transaction, the simulator constructs an off-chain eth_call test. At the moment of simulation, 0xContractA contains zero bytecode, so the simulated interaction returns successfully without state updates or warnings.
  3. The user signs the payload. The drainer network captures the signature and bundles it with a private block builder.
  4. The bundle contains two transactions executed atomically in sequence within a single block:
    • Transaction 1: A deployer contract calls CREATE2, deploying malicious bytecode to 0xContractA matching the precalculated salt.
    • Transaction 2: 0xContractA calls Permit2's permitTransferFrom, providing the victim signature. Permit2 validates the user signature against its internal state and forwards 50,000 $USDC from the user address to the attacker treasury.

Because the contract code did not exist when the simulation executed, the client software accurately reported that the prospective target could not initiate state transfers at that specific microsecond. The divergence between local prediction and atomic network execution resulted in the total loss of the balance.

Common Misconceptions

  • A green simulation check confirms a transaction is secure. Simulators only compute outputs based on the current isolated state. They cannot guarantee that state conditions will not change prior to block inclusion, nor can they detect vulnerabilities hidden inside uncalled external contract branches.
  • Signing off-chain messages cannot transfer tokens directly. While plain text messages cannot transfer assets, EIP-712 signatures matching schemas like Permit2 or seaport orders can be broadcast by third parties to execute transfers on the signer behalf without requiring direct gas expenditure from the signer.
  • Approvals must be submitted on-chain to present risk. Users often assume that without an on-chain approve transaction, wallet permissions remain untouched. Off-chain permits grant identical capabilities once an initial framework allowance has been established.

How This Connects to the Market

The continuous evolution of evasion techniques drives major shifts across decentralized software architecture. As static RPC simulations prove insufficient against dynamic execution tricks, client security is migrating toward real-time mempool inspection, bundle-level tracing, and predictive gas profiling.

Wallet developers are transitioning from basic eth_call parsers to specialized static analysis engines that decode nested EIP-712 payloads and flag any message granting counterparty rights to counterfactual addresses. Regulatory bodies, including European authorities under frameworks such as the Markets in Crypto-Assets (MiCA) regulation, emphasize institutional custodial security standards, forcing enterprise market participants to adopt multi-party computation (MPC) and strict policy engines over client-side extension warnings.

Questions this story raises

What is a transaction simulator in crypto wallets?
A transaction simulator is a client-side or RPC-level security tool that runs a prospective transaction through an isolated fork of the blockchain to show users the expected token inflows, outflows, and state changes before they sign.
Why do CREATE2 addresses bypass security simulations?
CREATE2 allows an address to be calculated and receive permissions before contract code is deployed. A simulator evaluating an undeployed address detects no malicious logic, but attackers can deploy the draining code in the same block the transaction executes.
How does Permit2 differ from standard ERC-20 approvals?
Standard ERC-20 approvals require an on-chain transaction for each contract. Permit2 allows users to grant a master allowance to a canonical contract, which then processes subsequent asset transfers using off-chain EIP-712 signatures.
Can transaction simulators prevent bundle attacks?
Basic transaction simulators cannot prevent bundle attacks because they evaluate transactions in isolation rather than modeling external state-changing transactions packaged together by private block builders.

References

  1. [1] EIP-712: Typed structured data hashing and signing — Ethereum Improvement Proposals
  2. [2] EIP-1014: Skinny CREATE2 — Ethereum Improvement Proposals
  3. [3] Permit2 Documentation — Uniswap Labs

Evergreen explainer written by Basis Desk's system and checked by an independent model pass for factual errors and advice language. Figures, fees and rules change — the references above are where to verify current specifics. Market figures marked "at the time of writing" come from live exchange data. Report an error: corrections@basisdesk.news · corrections policy.

The Daily Brief, in your inbox at 07:00 ET

Five stories, the numbers that moved, what to watch. Three minutes. No hype, no advice, unsubscribe in one click.

Not financial advice. Basis Desk publishes information, not recommendations. Crypto assets are volatile and you can lose what you invest.