# AnyswapV4Router: permit bypass drains 200 WETH via malicious token

AnyswapV4Router trusted a permit call on WETH, which lacks permit but has a fallback, allowing theft of 200 WETH from a victim who approved the router.

- Payout: Real-world hack
- Severity: high
- Program: AnyswapWETHPermit
- Credited: DeFiHackLabs
- Disclosed: 2025-07-29
- Write-up quality: 7/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2025-07/AnyswapWETHPermit_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20250729-anyswapwethpermit
- Tags: domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high technique:source-review vuln:business-logic vuln:signature-replay

**Target:** AnyswapV4Router contract on Ethereum
**Root cause:** The router called permit on the underlying token and assumed success meant a valid signature was enforced, but WETH's fallback accepts the call without validating the permit, so the router proceeded to transferFrom the victim's approved WETH.
**Steps:**
1. Deploy a malicious AnySwap-compatible token whose underlying() returns WETH and whose depositVault/burn functions are no-ops.
2. Call `router.anySwapOutUnderlyingWithPermit(victim, maliciousToken, attacker, 200 ether, deadline, 0, bytes32(0), bytes32(0), chainid)` with dummy permit data.
3. The router calls permit on WETH, which succeeds via fallback without checking signatures.
4. The router then calls transferFrom(victim, maliciousToken, 200 ether) using the victim's existing max approval.
5. Call `maliciousToken.sweep(attacker)` to transfer the received WETH to the attacker.
**How found:** Likely observed that WETH does not implement permit but has a fallback that accepts any call, and that the router did not verify permit success beyond the call not reverting.
**Exploitation:** Attacker used a malicious token contract with WETH as underlying to trick the router into calling permit on WETH, which silently succeeds, then the router transferred 200 WETH from a victim who had approved the router.
**Insight:** When a contract calls permit on a token, verify the token actually implements EIP-2612 and that the signature is validated; tokens with fallback functions can fake permit success.
