Reproduced Exploit

Liquorice: reBalance calls quoteExactInput and the supplied WETH is taken

reBalance transfers the pool's WETH to UniswapIntegration and then calls whatever _swapData the caller supplies. quoteExactInput returns 0, abi.decode accepts that 0, and nothing is swapped back. A following swap on the integration sends the stuck 5 WETH to the attacker. The pool and the integratio…

Oct 2024•Ethereum•access-control•3 min read

Loss

5 WETH of supplied liquidity leaves the pool and ends with the caller

Chain

Ethereum

Category

access-control

Date

Oct 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: 49434-arbitrary-call-in-lendingpoolrebalance-leads-to-asset-theft. Standalone Foundry PoC and full write-up: 49434-arbitrary-call-in-lendingpoolrebalance-leads-to-asset-theft_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/access-control/missing-auth

Key info#

FieldValue
Loss5 WETH of supplied liquidity leaves the pool and ends with the caller
Vulnerable contractLendingPool.reBalance
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-10
Compilersolc 0.8.27, cancun
Bug class_swapData is an unrestricted call into UniswapIntegration

TL;DR#

reBalance transfers the pool's WETH to UniswapIntegration and then calls whatever _swapData the caller supplies. quoteExactInput returns 0, abi.decode accepts that 0, and nothing is swapped back. A following swap on the integration sends the stuck 5 WETH to the attacker. The pool and the integration both end at 0.

The vulnerable code#

SOLIDITY
weth.transfer(address(uni), amount);
(bool ok, bytes memory result) = address(uni).call(_swapData); // @> VULN: _swapData can call any UniswapIntegration function, not only swap()
require(ok, "call");
decodedOut = abi.decode(result, (uint256));
DIFF
- (bool ok, bytes memory result) = address(uni).call(_swapData);
+ (bool ok, bytes memory result) = address(uni).call(
+     abi.encodeWithSelector(uni.swap.selector, tokenIn, address(this), amount)
+ );

Root cause#

The intended callee is swap. The parameter is raw calldata, so quoteExactInput is a valid target. Its uint256 return decodes as the expected amount-out and happens to be 0, which the pool does not reject. There is also no minAmount check. The tokens were transferred before the call, so a 0 result leaves them in the integration, where swap is permissionless.

Preconditions#

  • The lending pool holds 5 WETH of supplier liquidity.
  • UniswapIntegration.quoteExactInput returns 0.
  • swap transfers whatever token balance the integration holds.

Attack walkthrough#

  1. 5 WETH sits in the pool.
  2. The attacker calls reBalance with quoteExactInput selector data.
  3. The pool transfers 5 WETH to the integration.
  4. The arbitrary call returns 0. The pool decodes 0 and does not pull tokens back.
  5. The attacker calls swap and receives the 5 WETH.
  6. Pool and integration balances are 0.

Diagrams#

flowchart TD A["Pool holds 5 WETH of supplied liquidity"] --> B["reBalance is called with quoteExactInput calldata"] B --> C["5 WETH is transferred to UniswapIntegration"] C --> D["VULN call returns 0 and the pool decodes 0"] D --> E["swap sends the stuck WETH to the attacker"] E --> F["Pool and integration both hold 0"]

Impact#

Suppliers lose 5 WETH. The attacker holds the full amount. A hard-coded swap call, with a minimum amount out, would not leave the tokens sitting in the integration.

How to reproduce#

BASH
cd 49434-arbitrary-call-in-lendingpoolrebalance-leads-to-asset-theft_exp
forge test -vv

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.