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…
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
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.
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-registrymirror.
Vulnerability classes:
vuln/logic/price-calculation·vuln/arithmetic/precision-loss
Key info#
| Field | Value |
|---|---|
| Loss | Victim's 10 tokens are absorbed; attacker ends with 110 tokens plus 1 wei |
| Vulnerable contract | ClaggAaveAdapter._compoundAccounting |
| Attacker EOA | 0x1111111111111111111111111111111111111111 |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Local synthetic · 2024-12 |
| Compiler | solc 0.8.27, cancun, via IR |
| Bug class | totalLiquidity 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#
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#
- The attacker deposits 1 wei and receives 1 share.
- The attacker donates 100 tokens and compound sets total liquidity to the aToken balance.
- The victim deposits 10 tokens and receives 0 shares.
- The attacker withdraws. The victim's balance and share count are 0. The attacker holds 110 tokens plus 1 wei.
Diagrams#
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#
cd 46278-using-atokenbalanceof-in-claggaaveadapter-compoundaccounting_exp
forge test -vv
Sources#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/46278-using-atokenbalanceof-in-claggaaveadapter-compoundaccounting.md
- Cantina report: https://cdn.cantina.xyz/reports/cantina_clave_december2024.pdf
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 46278-using-atokenbalanceof-in-claggaaveadapter-compoundaccounting_exp (evm-hack-registry mirror).
- AuditVault finding: 46278-using-atokenbalanceof-in-claggaaveadapter-compoundaccounting.
Alerts & third-party analyses
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.