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.

Aug 2024•Ethereum•dos•3 min read

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

evm-hack-analyzer

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.

Loading fork state…

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-registry mirror.


Vulnerability classes: vuln/dos/frozen-funds · vuln/logic/missing-check

Key info#

FieldValue
Loss1200000 tokens stay in the capital pool. The maker receives 0
Vulnerable contractTokenManager.withdraw
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-08
Compilersolc 0.8.27, cancun, via IR
Bug classMissing 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#

SOLIDITY
_safe_transfer_from(_tokenAddress, pool, msg.sender, claimAbleAmount); // @> VULN

The inner call is token.transferFrom(capitalPool, maker, amount) while allowance is 0.

DIFF
  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#

  1. The maker is credited 1200000 tokens. The tokens sit in the pool.
  2. Allowance of TokenManager on the pool is 0.
  3. The maker calls withdraw. The claimable amount is the full refund.
  4. transferFrom reverts. The maker's wallet stays at 0 and the pool still holds 1200000 tokens.

Diagrams#

flowchart TD A["Maker is credited a refund held by the capital pool"] --> B["TokenManager allowance on that token is 0"] B --> C["Maker calls withdraw"] C --> D["VULN: transferFrom the pool with no prior approve"] D --> E["TransferFailed"] E --> F["1200000 tokens stay in the pool and the maker receives 0"] B --> G["Control calls capitalPool.approve when allowance is 0"] G --> H["Control withdraw pays the maker and empties the pool"]

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#

BASH
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#


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • 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.