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).
- Code is empty: no delegation is set.
- Code starts with
0xef0100and is 23 bytes long: a delegation is set; the last 20 bytes are the address it points to. - If you did not knowingly set that delegation, treat the wallet as compromised.
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:
- Move whatever is still in the wallet to a new wallet whose key has never been exposed.
- Do not send ETH for gas into the compromised wallet (see why gas deposits get swept).
- Stop using the old key for anything except a one-time rescue. Never paste a seed phrase, or the key of a wallet that is still safe, into any website.
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”.
- Open source: github.com/unsweep/unsweep. Rescue contract
0x38bcF425bC4d13624734e09376F2fafc799fA8c8, source verified on Sourcify (exact match): Base · Arbitrum · Basescan. - Which key, and where it goes: a rescue uses only the private key of the wallet that is already compromised, the one the attacker already has. Never your seed phrase and never the key of your new safe wallet. The key signs 100% inside your browser and is never sent to UNSWEEP or any server; only signatures are sent (see the exact signing code on GitHub). Check it yourself: open DevTools → Network before signing, and see the verified contract on Basescan. UNSWEEP never writes to you first.
- We never DM you: UNSWEEP never contacts anyone by DM, Telegram or Discord. Anyone who does is a scammer.
- Cost: free diagnostic, no upfront payment. Success fee only if the rescue executes, taken from the rescued tokens in the same transaction: 15% (<1,000 USD), 10% (1,000–10,000 USD), 5% (>10,000 USD); hard 15% maximum in the contract; shown in a simulation before you sign.
- Cannot rescue: funds already taken, NFTs, anything on Ethereum mainnet (read-only). Tokens outside the verified lists may be detected without guarantee. Nothing is guaranteed.