Reproduced Exploit
Zaros liquidation drops positive unrealized PnL and pays the liquidator only the collateral
liquidate reads unrealized PnL and then deducts maintenance from collateral only. The positive PnL is never minted.
Loss
300 USDZ of positive PnL is discarded. The liquidator is paid 900 instead of 1100, and the account is left at…
Chain
Ethereum
Category
logic
Date
Jul 2024
Source
AuditVault
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
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.
Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 37975-positive-pnl-is-lost-for-all-parties-when-liquidating-an-acc. Standalone Foundry PoC and full write-up: 37975-positive-pnl-is-lost-for-all-parties-when-liquidating-an-acc_exp in the
evm-hack-registrymirror.
Vulnerability classes: vuln/logic/unrealized-pnl · vuln/defi/liquidation
Key info#
| Field | Value |
|---|---|
| Loss | 300 USDZ of positive PnL is discarded. The liquidator is paid 900 instead of 1100, and the account is left at 0 instead of 100 |
| Vulnerable contract | Engine.liquidate |
| Attacker EOA | 0x1111111111111111111111111111111111111111 |
| Attack contract | Exploit at 0x15452ec016c4dc8c549e7fe6ff4b26324ea8b7a4 |
| Attack tx | Exploit.run() |
| Chain / block / date | Ethereum model · block 0 · 2024-07 |
| Compiler | solc 0.8.27, cancun, via IR |
| Bug class | Liquidation deducts collateral without minting positive unrealized PnL |
TL;DR#
liquidate reads unrealized PnL and then deducts maintenance from collateral only. The positive PnL is never minted.
The account has 900 collateral and +300 PnL. Maintenance is 1100. The vulnerable call treats 900 as the whole balance, transfers that 900 to the liquidator, and stores PnL as 0. The 300 is gone. The account balance is 0.
The fixed call mints 300 USDZ onto the account first. Collateral becomes 1200. It then transfers the 1100 maintenance and leaves 100.
The vulnerable code#
int256 pnl = unrealizedPnl[user];
uint256 col = collateral[user];
uint256 margin = col;
require(requiredMaintenance > margin, "healthy");
require(requiredMaintenance > margin && pnl > 0, "healthy");
usdz.transfer(msg.sender, take); // @> VULN: pays the 900 collateral; the +300 PnL was never minted
The quoted liquidateAccounts path loads unrealized PnL, checks maintenance against margin, and calls deductAccountMargin without the mint that SettlementBranch performs for a positive PnL.
Impact#
300 USDZ of positive PnL is not minted and is not paid. The liquidator receives 900 instead of 1100. The account is emptied instead of keeping 100.
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 37975-positive-pnl-is-lost-for-all-parties-when-liquidating-an-acc_exp (evm-hack-registry mirror).
- AuditVault finding: 37975-positive-pnl-is-lost-for-all-parties-when-liquidating-an-acc.
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.