Reproduced Exploit

Entangle Trillion — callback reentrancy drains bridge withdrawals

withdraw transfers a callback-capable token before decrementing tokenStorage. A receiver re-enters twice during the token callback, so a nominal 100-token withdrawal drains the whole 300-token bridge reserve.

Feb 2024Otherreentrancy2 min read

Chain

Other

Category

reentrancy

Date

Feb 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. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 51374-re-entrancy-causes-draining-of-funds-through-withdraw-swapto. Standalone Foundry PoC and full write-up: 51374-re-entrancy-causes-draining-of-funds-through-withdraw-swapto_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/reentrancy/single-function · vuln/logic/wrong-order

Reproduction: Fully local, cheatcode-free synthetic. Run forge test -vvv in this folder.

Key info#

FieldValue
ProtocolEntangle Trillion
FindingAuditVault 51374
ImpactHigh
ReproductionLocal synthetic; no mainnet fork
Vulnerable contractEntangleTestBridge
CompilerSolidity 0.8.24

TL;DR#

withdraw transfers a callback-capable token before decrementing tokenStorage. A receiver re-enters twice during the token callback, so a nominal 100-token withdrawal drains the whole 300-token bridge reserve.

Vulnerable code#

The minimized contract preserves the reported operation with an @> VULN marker in the synthetic.

Root cause#

The balance check and the accounting decrement are separated by an external token transfer. An ERC677 or ERC777-style receiver can call back into withdraw while the original storage value is still available to every nested call.

Preconditions#

The bridge holds a callback-capable token and has enough recorded liquidity for at least one withdrawal. The attacker controls a token receiver implementing the callback.

Attack walkthrough#

The local bridge begins with 300 tokens. The receiver requests 100, receives the token callback, and recursively withdraws two more times. The proof ends with 300 tokens in the receiver and zero recorded bridge liquidity.

Diagrams#

flowchart TD A["Receiver requests 100 tokens"] --> B["Bridge checks 300-token storage"] B --> C["Bridge transfers callback token"] C --> D["Receiver re-enters withdraw twice"] D --> E["Receiver drains 300 tokens"]

Impact#

A malicious callback receiver can withdraw multiple times against one apparent balance check, exhausting bridge reserves. The synthetic asserts the threefold 300-token transfer on chain.

Remediation#

Apply checks-effects-interactions: decrement tokenStorage[address(token)] before the external transfer. A reentrancy guard provides an additional defense for all external withdrawal entry points.

How to reproduce#

BASH
cd /workspaces/RustroverProjects/audits/evm-hack-registry/51374-re-entrancy-causes-draining-of-funds-through-withdraw-swapto_exp
forge test -vvv

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.