How UNSWEEP Tests and Verifies Its EIP-7702 Token Recovery Contracts
When a wallet's private key is compromised by a sweeper bot, sending ETH for gas to rescue remaining ERC-20 tokens usually fails—the bot drains the gas before the recovery transaction lands. UNSWEEP (unsweep/unsweep, MI
When a wallet's private key is compromised by a sweeper bot, sending ETH for gas to rescue remaining ERC-20 tokens usually fails—the bot drains the gas before the recovery transaction lands.
UNSWEEP (unsweep/unsweep, MIT) uses EIP-7702 delegation plus a relayer so a compromised EOA can sign a rescue intent locally in the browser without funding gas on the compromised address.
Because asking users to sign with a compromised private key is inherently sensitive, claiming "it's safe" is useless. Instead, we published a reproducible technical evidence package so any developer or security researcher can verify the contracts, tests, static analysis, and production frontend independently.
Disclaimer: This is not a third-party professional audit. It is a reproducible engineering baseline (Foundry + Slither + bytecode/hash checks + manual review) with open findings documented transparently.
1. Contract Testing with Foundry
The core delegate contract (src/UnsweepDelegate.sol) is compiled with solc 0.8.39 (EVM prague, optimizer 200, via_ir) and tested with Foundry (forge 1.10.0).
git clone [https://github.com/unsweep/unsweep.git](https://github.com/unsweep/unsweep.git)
cd unsweep
forge build
forge test -vv
Current baseline (docs/security/forge-test.txt):
-
36 tests passed, 0 failed, 0 skipped across 4 suites:
Unsweep.t.sol,Hardening.t.sol,M4.t.sol, andM4c.t.sol. - Key invariants covered:
-
EIP-712 domain & replay protection:
verifyingContractis the EOA itself, high-ssignatures are rejected, bitmap nonces prevent replay, anddeadlinebounds execution. -
Transient reentrancy lock:
tload/tstoreguard around rescue execution. -
Cross-stack digest parity: Python tests (
relayer/test_typehash_parity.pyandrelayer/test_digest_parity_appjs.py) verify that Solidity, Python (relayer/eip712.py), and the browser'sweb/assets/app.jsproduce identical EIP-712RESCUE_TYPEHASHand digests.
-
EIP-712 domain & replay protection:
2. Static Analysis (Slither)
Running Slither (0.11.6) against the project contracts:
slither . --filter-paths "lib/|node_modules/|test/|script/"
Out of 25 filtered findings in UnsweepDelegate.sol (raw outputs in docs/security/):
-
1 High (
reentrancy-balance, line 134): Justified false positive. The function is guarded by a transient storage lock (tload/tstore), and pre/postbalanceOfreads intentionally measure actual received amounts to bound fees. -
1 Real Low (
locked-ether, line 21 /receiveline 91): ETH sent directly to the implementation contract address is locked (EOAs delegating via EIP-7702 still control their own ETH). - Remaining items are
calls-loop(by design),timestamp(deadline),reentrancy-events, and informational notes.
3. Verifying On-Chain Bytecode & Production Frontend
Tests in a repo only matter if production matches the repo.
On-Chain Bytecode (Base & Arbitrum One)
Both contracts are deployed at:
-
UnsweepDelegate:0x38bcF425bC4d13624734e09376F2fafc799fA8c8 -
UnsweepConfig:0x56a345661e3999F2b20f1E069aAC14097Fa0D118
On Base, both contracts have verified source code on Basescan. On Arbitrum One (checked at block 527221874), the runtime bytecode (6059 B Delegate, 881 B Config) matches forge build at HEAD byte-for-byte once immutable references are masked.
Production Frontend Hash Check
The signing logic lives in web/assets/app.js (the private key is used locally with ethers.js and never sent to /api/rescue). Anyone can verify that the script served by https://unsweep.com matches the repository:
curl -s [https://unsweep.com/assets/app.js](https://unsweep.com/assets/app.js) | sha256sum
sha256sum web/assets/app.js
4. Known Limitations (Documented Openly)
We track unresolved issues publicly in SECURITY_EVIDENCE.md and our HackMD security summary:
-
C-1 / R-5(Medium): InUnsweepDelegate.sol,minFees[j]is bounded by token balance (bal) rather thanMAX_FEE_BPS(15%). While the relayer enforces the 15% cap during quoting, submission only checks theminFeesarray length. Exploiting this still requires the victim's EIP-712 signature, but it is a real gap to close. -
W-7(Low):readKey()clears the private key input (#pk) from the DOM when signing starts, but early validation returns or navigating back between steps do not clear it yet. - No third-party audit yet: Independent review of the contracts, relayer, and frontend is still needed.
Feedback Welcome
If you work on Solidity, EIP-7702, or Web3 security, we'd appreciate critical review:
- Repo: https://github.com/unsweep/unsweep
- Security Evidence Summary: https://hackmd.io/@Unsweep/unsweep
- Full Report & Raw Outputs: https://github.com/unsweep/unsweep/blob/main/docs/SECURITY_EVIDENCE.md
Open an issue or PR if you find anything we missed.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.