Reproduced Exploit
Tadle: maker refunds revert until someone approves the capital pool
TokenManager.withdraw credits a maker refund and then pulls the tokens from the capital pool. The ERC20 branch never checks allowance and never calls capitalPool.approve. With a fresh token the pull reverts, so the maker cannot withdraw until somebody approves TokenManager by hand.
Loss
1200000 tokens stay in the capital pool. The maker receives 0
Chain
Ethereum
Category
dos
Date
Aug 2024
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. 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. Reproduction of a public audit finding curated by AuditVault — the original finding: 38072-token-withdrawal-fails-until-someone-manually-approves-spend. Standalone Foundry PoC and full write-up: 38072-token-withdrawal-fails-until-someone-manually-approves-spend_exp in the
evm-hack-registrymirror.
Vulnerability classes:
vuln/dos/frozen-funds·vuln/logic/missing-check
Key info#
| Field | Value |
|---|---|
| Loss | 1200000 tokens stay in the capital pool. The maker receives 0 |
| Vulnerable contract | TokenManager.withdraw |
| Attacker EOA | 0x1111111111111111111111111111111111111111 |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Ethereum model · block 0 · 2024-08 |
| Compiler | solc 0.8.27, cancun, via IR |
| Bug class | Missing allowance before transferFrom the capital pool |
TL;DR#
TokenManager.withdraw credits a maker refund and then pulls the tokens from the capital pool. The ERC20 branch never checks allowance and never calls capitalPool.approve. With a fresh token the pull reverts, so the maker cannot withdraw until somebody approves TokenManager by hand.
Background#
CodeHawks Tadle contest, August 2024, reported by p0wd3r. The contest trace shows transferFrom reverting ERC20InsufficientAllowance for 1200000000000000000000000 units, then TransferFailed. _transfer already approves the pool when allowance is zero. withdraw skips that helper and calls _safe_transfer_from directly. The amount in this run is that same 1.2e24.
The vulnerable code#
_safe_transfer_from(_tokenAddress, pool, msg.sender, claimAbleAmount); // @> VULN
The inner call is token.transferFrom(capitalPool, maker, amount) while allowance is 0.
address pool = capitalPoolAddr;
+ if (IERC20(_tokenAddress).allowance(pool, address(this)) == 0) {
+ ICapitalPool(pool).approve(_tokenAddress);
+ }
_safe_transfer_from(_tokenAddress, pool, msg.sender, claimAbleAmount);
Root cause#
The withdraw path assumes the capital pool has already approved TokenManager. Nothing in this function creates that approval, and a new whitelisted token starts at allowance 0.
Preconditions#
- The capital pool holds the token.
- TokenManager's allowance on that token is 0.
- The maker's claimable balance is non-zero. This run uses balance type 4, the maker-refund bucket from the trace.
Attack walkthrough#
- The maker is credited 1200000 tokens. The tokens sit in the pool.
- Allowance of TokenManager on the pool is 0.
- The maker calls
withdraw. The claimable amount is the full refund. transferFromreverts. The maker's wallet stays at 0 and the pool still holds 1200000 tokens.
Diagrams#
Impact#
For a newly whitelisted token, every maker refund reverts until an outside caller approves TokenManager. The 1200000 token refund in this run never leaves the capital pool.
Remediation#
Before the pull, if allowance is 0, call capitalPool.approve(token), which is what TokenManagerFixed.withdraw does. The control then pays the full refund.
How to reproduce#
cd 38072-token-withdrawal-fails-until-someone-manually-approves-spend_exp
forge test -vv
test_exploit_withdraw_reverts_until_allowance asserts the withdraw fails and the pool still holds 1200000 tokens. test_control_approve_lets_withdraw_succeed asserts the approve-then-pull pays the caller. Captured output is output.txt.
Sources#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/38072-token-withdrawal-fails-until-someone-manually-approves-spend.md
- Contest: https://codehawks.cyfrin.io/c/2024-08-tadle
- Blamed source: https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/TokenManager.sol
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 38072-token-withdrawal-fails-until-someone-manually-approves-spend_exp (evm-hack-registry mirror).
- AuditVault finding: 38072-token-withdrawal-fails-until-someone-manually-approves-spend.
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.