Reproduced Exploit

QuantAMM: the uplift hook locks the owner swap fee in itself

onAfterSwap tells the vault to send the owner fee to the hook contract. The hook never exposes a transfer out. After a swap that charges 1 token, the hook holds that token and the owner balance is still 0. Sending the same fee to owner() leaves the hook empty.

Dec 2024•Ethereum•dos•3 min read

Loss

1 token of owner fee locked in UpliftOnlyExample. Owner balance stays 0

Chain

Ethereum

Category

dos

Date

Dec 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: 49688-owner-fee-will-be-locked-in-upliftonlyexample-contract-due-t. Standalone Foundry PoC and full write-up: 49688-owner-fee-will-be-locked-in-upliftonlyexample-contract-due-t_exp in the evm-hack-registry mirror.


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

Key info#

FieldValue
Loss1 token of owner fee locked in UpliftOnlyExample. Owner balance stays 0
Vulnerable contractUpliftOnlyExample.onAfterSwap
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-12
Compilersolc 0.8.27, cancun, via IR
Bug classsendTo pays address(this) and the hook has no withdraw

TL;DR#

onAfterSwap tells the vault to send the owner fee to the hook contract. The hook never exposes a transfer out. After a swap that charges 1 token, the hook holds that token and the owner balance is still 0. Sending the same fee to owner() leaves the hook empty.

Background#

CodeHawks contest on Cyfrin's December 2024 QuantAMM repository. UpliftOnlyExample.onAfterSwap is the post-swap hook. The report's Foundry log showed the hook USDC balance rising to 1e18 while the owner stayed at 0.

The vulnerable code#

SOLIDITY
if (ownerFee > 0) {
    // @> VULN: owner fee is sent to this hook, which has no function that can transfer it out
    _vault.sendTo(feeToken, address(this), ownerFee);
    emit SwapHookFeeCharged(address(this), feeToken, ownerFee);
}

Vault.sendTo transfers ownerFee of feeToken from the vault to the to argument. That argument is address(this).

Root cause#

The recipient is the hook, not owner(). No later function moves tokens out of the hook.

Preconditions#

  • The vault holds at least the fee. This run prefunds 1 token.
  • A swap calls onAfterSwap with ownerFee of 1 token. Any caller of the hook can do that. The owner is not required.

Attack walkthrough#

  1. onAfterSwap is called with a 1 token fee.
  2. sendTo transfers that token from the vault to the hook.
  3. The hook balance is 1 token. The owner balance is 0. The vault balance is 0.
  4. The control hook passes owner() as the recipient. The owner receives the token and the hook stays empty.

Diagrams#

flowchart TD A["Swap charges a 1 token owner fee"] --> B["onAfterSwap calls vault sendTo"] B --> C["VULN recipient is the hook itself"] C --> D["Hook balance becomes 1 token"] D --> E["Owner balance stays 0 and no withdraw exists"] B --> F["Control sends the same fee to owner"] F --> G["Owner receives 1 token and the hook stays empty"]

Impact#

Every owner fee charged by this hook is stuck in the contract. The owner cannot collect it. This run locks 1 token. The same path locks every later fee.

Remediation#

Call _vault.sendTo(feeToken, owner(), ownerFee).

How to reproduce#

BASH
cd 49688-owner-fee-will-be-locked-in-upliftonlyexample-contract-due-t_exp
forge test -vv

test_exploit_owner_fee_locked_in_hook asserts the hook holds 1 token and the owner holds 0. test_control_fee_reaches_owner asserts the reverse. 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.