Reproduced Exploit
TrustSwap LockToken: withdrawTokens transfers before clearing nftMinted
Chain
Other
Category
reentrancy
Date
Aug 2022
Source
AuditVault
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. No backend, no live RPC.
Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 57521-reentrancy-in-main-functions-zokyo-none-trustswap-markdown. Standalone Foundry PoC and full write-up: 57521-reentrancy-in-main-functions-zokyo-none-trustswap-markdown_exp in the
evm-hack-registrymirror.
Vulnerability classes: vuln/reentrancy/single-function
Reproduction: faithful local reproduction of AuditVault 57521.
withdrawTokenscallstoken.transferandnft.burnbeforenftMinted[id] = false. A token callback re-enters the same id and pulls the deposit a second time.
Root cause#
Zokyo's TrustSwap review of LockToken.withdrawTokens reports external transfer and burn calls before nftMinted[id] is written false. While the flag is still true, the same id can be withdrawn again.
uint256 amount = depositOf[id];
// @> VULN: external transfer and burn run before nftMinted[id] is cleared
token.transfer(msg.sender, amount);
nft.burn(id);
nftMinted[id] = false;
Attack path#
Impact#
The attacker deposited 1,000 LOCK and finished with that principal back. The other locker's 1,000 LOCK was transferred as well and forwarded to the sink. A fixed withdrawTokens clears nftMinted before the external calls, the reentered withdraw reverts, and the victim lock stays intact.
PoC#
cd 57521-reentrancy-in-main-functions-zokyo-none-trustswap-markdown_exp
forge test -vv
Sources#
- AuditVault finding 57521
- Zokyo, TrustSwap, 2022-08-08: https://github.com/solodit/solodit_content/blob/main/reports/Zokyo/2022-08-08-TrustSwap.md
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 57521-reentrancy-in-main-functions-zokyo-none-trustswap-markdown_exp (evm-hack-registry mirror).
- AuditVault finding: 57521-reentrancy-in-main-functions-zokyo-none-trustswap-markdown.
Alerts & third-party analyses
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.