Reproduced Exploit

Clave Clagg: an aToken donation inflates the vault and the next depositor mints 0 shares

_compoundAccounting sets totalLiquidity to aToken.balanceOf. The attacker deposits 1 wei, donates 100 tokens, and compounds. The next 10 token deposit rounds to 0 shares. The attacker's 1 share then withdraws the donation and the victim's deposit. The attacker ends holding 110 tokens plus 1 wei. Th…

Dec 2024•Other•logic•3 min read

Loss

Victim's 10 tokens are absorbed; attacker ends with 110 tokens plus 1 wei

Chain

Other

Category

logic

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: 46278-using-atokenbalanceof-in-claggaaveadapter-compoundaccounting. Standalone Foundry PoC and full write-up: 46278-using-atokenbalanceof-in-claggaaveadapter-compoundaccounting_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/price-calculation · vuln/arithmetic/precision-loss

Key info#

FieldValue
LossVictim's 10 tokens are absorbed; attacker ends with 110 tokens plus 1 wei
Vulnerable contractClaggAaveAdapter._compoundAccounting
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateLocal synthetic · 2024-12
Compilersolc 0.8.27, cancun, via IR
Bug classtotalLiquidity is set from aToken.balanceOf

TL;DR#

_compoundAccounting sets totalLiquidity to aToken.balanceOf. The attacker deposits 1 wei, donates 100 tokens, and compounds. The next 10 token deposit rounds to 0 shares. The attacker's 1 share then withdraws the donation and the victim's deposit. The attacker ends holding 110 tokens plus 1 wei. The victim holds 0 shares and 0 tokens.

The vulnerable code#

SOLIDITY
function compound() external {
    poolInfo.totalLiquidity = token.balanceOf(address(this));
}

Share minting divides the deposit by totalLiquidity / totalShares. A direct aToken balance includes donations, so a 1 wei share can be priced above the next deposit.

Root cause#

Accounting uses the raw aToken balance. A donation changes the share price without minting shares.

Preconditions#

  • The vault is empty.
  • The attacker can donate aTokens to the vault and call compound.
  • A later depositor adds 10 tokens.

Attack walkthrough#

  1. The attacker deposits 1 wei and receives 1 share.
  2. The attacker donates 100 tokens and compound sets total liquidity to the aToken balance.
  3. The victim deposits 10 tokens and receives 0 shares.
  4. The attacker withdraws. The victim's balance and share count are 0. The attacker holds 110 tokens plus 1 wei.

Diagrams#

flowchart TD A["Attacker deposits 1 wei for 1 share"] --> B["Donate 100 tokens and compound"] B --> C["totalLiquidity is the raw aToken balance"] C --> D["Victim deposits 10 tokens and mints 0 shares"] D --> E["Attacker withdraws 110 tokens plus 1 wei"]

Impact#

The first share can be inflated until later deposits mint nothing and can be withdrawn by the first depositor. This run takes the victim's 10 tokens on top of the donated 100, which the attacker supplied.

How to reproduce#

BASH
cd 46278-using-atokenbalanceof-in-claggaaveadapter-compoundaccounting_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.