Reproduced Exploit

Fungify liquidation reverts after interest was already accrued in the block

liquidate uses the return value of accrueInterest as the exchange rate. If this block already accrued, accrueInterest returns 0. The freshness check reverts when that rate is 0.

Nov 2023•Ethereum•logic•2 min read

Loss

100 of collateral is not seized. Liquidation reverts because a same-block accrue returns 0

Chain

Ethereum

Category

logic

Date

Nov 2023

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack replays in your browser. Step through it by Solidity line or by opcode.

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: 62381-fng-15-cerc721-liquidation-will-always-revert-if-interest-st. Standalone Foundry PoC and full write-up: 62381-fng-15-cerc721-liquidation-will-always-revert-if-interest-st_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/liquidation-freshness · vuln/dos/blocked-liquidation

Key info#

FieldValue
Loss100 of collateral is not seized. Liquidation reverts because a same-block accrue returns 0
Vulnerable contractCToken.liquidate
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit at 0x15452ec016c4dc8c549e7fe6ff4b26324ea8b7a4
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2023-11
Compilersolc 0.8.27, cancun, via IR
Bug classaccrueInterest returns 0 on the same-block short-circuit and the freshness check treats that as stale
flowchart TD A["First accrueInterest in the block stores the block and returns 2 ether"] --> B["Second accrue hits the short-circuit"] B --> C["The short-circuit returns 0"] C --> D["VULN freshness check sees the zero rate and reverts"] D --> E["100 of collateral stays in the market"] B --> F["Control returns the stored 2 ether rate"] F --> G["Liquidation seizes the 100"]

TL;DR#

liquidate uses the return value of accrueInterest as the exchange rate. If this block already accrued, accrueInterest returns 0. The freshness check reverts when that rate is 0.

The market holds 100 of collateral and an exchange rate of 2 ether. The first accrue in the transaction returns 2 ether and records the block. The liquidation's accrue then returns 0, and LiquidateFreshnessCheck reverts. collateral is still 100 and nothing is seized.

The fixed accrue returns the stored exchange rate on that short-circuit. Liquidation seizes the 100.

The vulnerable code#

SOLIDITY
if (accrualBlockNumber == currentBlockNumber) {
    return NO_ERROR;
}
if (accrualBlockNumber != block.number || assetsExchangeRate == 0) {
    lastSeized = assetsExchangeRate; // @> VULN: the same-block accrue returned 0, so the 100 is not seized
    return 0;
}

NO_ERROR is 0. The quoted _liquidateBorrow reverts with LiquidateFreshnessCheck on that 0. This model takes the same branch and returns without seizing.

Impact#

A liquidation that should seize 100 of collateral reverts. The collateral stays in the market. Calling accrueInterest earlier in the same block is enough to cause it.


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.