Reproduced Exploit
Unifund — a cyclic swap path double-counts WETH, and withdraw pays the phantom from the core
Unifund lets a group swap its pooled funds along an arbitrary Uniswap V2 path. A path that starts and ends on WETH should net about zero WETH. The swap facet instead accounts the input leg and the output leg as separate deltas against the same group ledger key, so the round trip is recorded as a WE…
Chain
Ethereum
Category
logic
Date
Nov 2026
Source
DeFiHackLabs
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
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.
Source & credit. Exploit reproduction, trace data, and analysis adapted from DeFiHackLabs by SunWeb3Sec — an open registry of reproduced on-chain exploits. Standalone Foundry PoC and full write-up: 2026-11-Unifund_exp in the
evm-hack-registrymirror. Upstream DeFiHackLabs PoC:src/test/…/Unifund_exp.sol.
Vulnerability classes: vuln/logic/missing-validation · vuln/logic/state-update Reproduction: the PoC compiles and runs in an isolated Foundry project at this project folder. Full verbose trace: output.txt. The trace forks Ethereum mainnet at block 26,388,566 and
[PASS] testExploitplus[PASS] testControlNonCyclic.
Key info#
| Profit | 0.655850116316355546 ETH net to the attacker after repaying a 12 WETH Balancer flash loan. The core loses 4.628136547384151187 WETH of the 4.994488833099649474 WETH it held |
| Vulnerable contracts | Unifund core 0x152ad66bd57da8d539abaaf98d7c378621c36227, unverified diamond. Swap facet 0x489176b37cb9da4149940707ce39135adc41cec5, unverified |
| Attacker EOA | 0x6ee1702ca602ddab66f984aaebaac0451068f881 |
| Exploit tx | 0x5f1e276e99e63289dd4932ad18a96d7642cbdc92241652ee175271b3e63027a0 (one of five) |
| Flash source | Balancer V2 Vault 0xba12222222228d8ba445958a75a0704d566bf2c8 |
| Chain / block | Ethereum mainnet / fork block 26,388,566 / 2026-11 |
| Bug class | swapExactTokensForTokens accepts path[0] == path[last] and books the WETH spent and the WETH received as two credits on one ledger key |
TL;DR#
Unifund lets a group swap its pooled funds along an arbitrary Uniswap V2 path. A path that starts and ends on WETH should net about zero WETH. The swap facet instead accounts the input leg and the output leg as separate deltas against the same group ledger key, so the round trip is recorded as a WETH gain. finish() then withdraw() pay that phantom balance out of the core's shared pool, which holds other groups' funds.
The whole sequence is reachable by a fresh contract. No role, no vm.prank of a protocol address, and no minted WETH: the 12 WETH working capital is a real Balancer flash loan, repaid in the callback. A control with the same setup and a non-cyclic path WETH -> A -> B does not drain the core.
The core and the swap facet are unverified, so the playground marks the cyclic swapExactTokensForTokens call in the exploit. The loss is measured on the core's real WETH balance.
The call#
// test/Unifund_exp.sol — first of the two cyclic swaps
// @> VULN: a cyclic path WETH->A->B->WETH is booked as a WETH gain instead of a net of about zero
UNIFUND.swapExactTokensForTokens(groupId, 1e15, 0, path, block.timestamp);
path is WETH, A, B, WETH. A and B are scratch ERC20s the attacker deploys, and the three Uniswap V2 pairs are seeded so the round trip is routable. The ids on the real selectors are uint64 and three create params are uint16. A uint256 interface hits the wrong facet and reverts.
Diagrams#
Remediation#
- Reject a path whose first and last token are equal, or net the two WETH deltas before crediting the group.
- Pay
withdrawonly from that group's own balance, not from a shared core balance that other groups funded. - Verify and publish the diamond facets so the accounting can be checked against the interface.
How to reproduce#
Offline, from this folder, with the committed anvil_state.json:
bash ../_shared/run-poc/run_poc.sh 2026-11-Unifund_exp -vv
testExploit asserts the core drop is about 4.628 WETH. testControlNonCyclic runs the same body on WETH -> A -> B and asserts the core is not drained.
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 2026-11-Unifund_exp (evm-hack-registry mirror).
- Upstream DeFiHackLabs PoC:
Unifund_exp.sol. - Attack transaction: view on explorer.
Alerts & third-party analyses
- DeFiHackLabs incident explorer: search "Unifund".
- 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.