UNSWEEP › Guides

Malicious EIP-7702 delegation: how to detect it and how to revoke or mitigate it

This guide is informational. Funds already moved out of a compromised wallet cannot be recovered. Revoking a delegation only protects what is still in the wallet, and only if the private key is not also in the attacker's hands.

Check whether an address has a delegation set with the free, read-only diagnostic: https://unsweep.com/ (no keys, no signatures).

Current scope of UNSWEEP: Base: 16 verified tokens. Arbitrum: 12 verified tokens. Other ERC-20 tokens may be detected, but without any guarantee. Ethereum: read-only diagnostic only (no rescue). Funds already taken cannot be recovered, and NFTs are not rescued. See what can and cannot be rescued and the step-by-step rescue guide. Start with the free diagnostic.

What an EIP-7702 delegation is

EIP-7702 (“Set Code for EOAs”, status: Final) lets a normal wallet (an externally-owned account) point to contract code. It adds a transaction type SET_CODE_TX_TYPE = 0x04 with an authorization_list of tuples [chain_id, address, nonce, y_parity, r, s]. When an authorization is processed, the specification says: “Set the code of authority to be 0xef0100 || address. This is a delegation indicator.”

The authorization is signed by the wallet's own key: “Let authority = ecrecover(msg, y_parity, r, s)”, where “msg = keccak(MAGIC || rlp([chain_id, address, nonce]))” and MAGIC = 0x05. After that, calls to the wallet run the code at the delegated address.

What makes a delegation malicious

A delegation is malicious when the delegated code serves someone other than the owner, for example code that lets a third party move the wallet's tokens or that forwards incoming funds elsewhere. This can happen if the owner is tricked into signing an authorization, or if an attacker who already has the private key signs one. The delegation stays in the account's code until it is replaced or cleared, so the delegated code runs whenever the wallet is called. Persistence does not mean the code runs automatically on every incoming payment: an ordinary ERC-20 transfer updates balances inside the token contract without calling the receiving wallet (EIP-20 – transfer). The risk is that the delegated code may let a third party move assets that are, or later become, held by the wallet.

The chain ID inside an authorization matters. The specification requires the node to “verify the chain ID is 0 or the ID of the current chain”, so an authorization signed with chain_id = 0 is accepted on any chain where EIP-7702 is active, not just one (EIP-7702 – Specification).

How to detect it

A wallet with no delegation has no code. A delegated wallet's code is exactly the delegation indicator: the 3-byte prefix 0xef0100 followed by the 20-byte delegated address. The specification notes that EXTCODESIZE returns 23, “the size of 0xef0100 || address” (EIP-7702 – Delegation indicator).

This check is read-only and needs no keys. The free diagnostic performs it for you.

How to revoke or mitigate it

Revoke: the specification defines a reset: if the authorization's address is 0x0000000000000000000000000000000000000000, the delegation is cleared instead of set, and the account's code returns to empty (EIP-7702 – Behavior). The owner signs this new authorization with the wallet's key, locally, and each processed authorization increases the wallet's nonce: “Increase the nonce of authority by one.” A revocation applies to the chain where it is processed, so check every chain on which the wallet is used.

Limits: if the attacker also has the private key, they can sign a new delegation after you clear it. In that case revoking alone does not secure the wallet:

Start by checking the address: https://unsweep.com/.

Related: EIP-7702 sweeper delegation · Revoke token approvals · Compromised wallet checklist

Source: EIP-7702: Set Code for EOAs · ethereum.org Accounts

Related guides: Why ETH sent for gas gets stolen immediately · Rescue USDC and WETH from a hacked wallet on Base · Rescue tokens from a hacked wallet on Arbitrum · Sweeper bot vs malicious EIP-7702 delegation · How to check if a wallet has a sweeper bot · What to do in the first 5 minutes after a wallet hack · Sweeper bot on a hacked wallet · Step-by-step rescue · What can and cannot be rescued
MetaMask is a trademark of its owner, referenced descriptively; UNSWEEP is not affiliated with MetaMask or Consensys.

Before you start: trust facts

Sounds familiar? “My funds disappear as soon as they arrive” · “I can’t pay for gas because the ETH is taken instantly” · “My wallet was hacked and I can’t get my tokens out”.