Reproduced Exploit

Biconomy Nexus: enable-mode signature can be replayed

The enable-mode digest is keccak256(abi.encode(MODULE_ENABLE_MODE_TYPE_HASH, module, keccak256(initData))). It does not include the user operation hash. The owner signs that digest once. After they uninstall the module, a second user operation with a different hash still validates, reinstalls the m…

Oct 2024•Ethereum•auth•3 min read

Loss

1000 USDC pulled from the account after the owner uninstalled the module

Chain

Ethereum

Category

auth

Date

Oct 2024

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 43810-enable-mode-signature-can-be-replayed-spearbit-none-biconomy. Standalone Foundry PoC and full write-up: 43810-enable-mode-signature-can-be-replayed-spearbit-none-biconomy_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/auth/signature-replay

Key info#

FieldValue
Loss1000 USDC pulled from the account after the owner uninstalled the module
Vulnerable contractAccount._getEnableModeDataHash
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-10
Compilersolc 0.8.27, cancun, via IR
Bug classEnable-mode digest omits userOpHash

TL;DR#

The enable-mode digest is keccak256(abi.encode(MODULE_ENABLE_MODE_TYPE_HASH, module, keccak256(initData))). It does not include the user operation hash. The owner signs that digest once. After they uninstall the module, a second user operation with a different hash still validates, reinstalls the module, and the module's onInstall transfers the 1000 USDC that arrived in between.

The vulnerable code#

SOLIDITY
digest = _hashTypedData(
    keccak256(abi.encode(MODULE_ENABLE_MODE_TYPE_HASH, module, keccak256(initData))) // @> VULN: userOpHash is not in the enable-mode digest, so one signature installs the module again
);

The type string is ModuleEnableMode(address module,bytes32 initDataHash), matching the pre-fix Nexus hash. The recommended fix adds userOpHash (and the module type) to the struct, so the entry-point nonce that already binds a user operation also binds the enable-mode signature.

Preconditions#

  • The owner has installed a validator that accepts a digest it has signed.
  • The signed payload names a module whose onInstall calls execute and sends the account's tokens to a fixed recipient.
  • The owner uninstalls that module. Later, 1000 USDC is credited to the account.
  • A bundler submits a new user operation that carries the old enable-mode signature and a different userOpHash.

Attack walkthrough#

  1. The owner signs the digest of the module and the recipient init data. The signature is used once.
  2. The first enable installs the module. The account is empty, so nothing moves. The owner uninstalls it.
  3. 1000 USDC is minted to the account.
  4. The same signature and init data are submitted with a new userOpHash. The digest is unchanged, so the validator still accepts it.
  5. The module is installed again and execute sends the 1000 USDC to the caller.
  6. The control hashes userOpHash into the struct. The second user operation reverts and the 1000 USDC stays on the account.

Diagrams#

flowchart TD A["Owner signs module plus init data once"] --> B["First user operation installs the module"] B --> C["Owner uninstalls it"] C --> D["1000 USDC arrives on the account"] D --> E["VULN: digest ignores the new userOpHash"] E --> F["Same signature reinstalls the module"] F --> G["onInstall sends the 1000 USDC to the caller"] E --> H["Control binds userOpHash into the digest"] H --> I["Second user operation reverts and the funds stay"]

Impact#

The account owner removed the module and then received 1000 USDC. The old enable-mode signature installs that module again and the module transfers all 1000 USDC to the caller. The owner did not sign the second user operation.

How to reproduce#

BASH
cd 43810-enable-mode-signature-can-be-replayed-spearbit-none-biconomy_exp
forge test -vv

test_exploit_replays_enable_mode_signature asserts the module is reinstalled and the account balance is 0. test_control_user_op_hash_stops_replay asserts the bound digest rejects the second hash and the attacker is paid nothing.

Sources#


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.