Reproduced Exploit

Level: mintDefault does not reprice the order

mintDefault checks that the caller is the benefactor and then passes the order straight to _mint. It never calls computeCollateralOrlvlUSDAmount. A registered minter sets lvlusd_amount to 100 and collateral_amount to 1 wei, mints 100 unbacked lvlUSD, and redeems it against the 100 USDC another mint…

Sep 2024•Ethereum•input-validation•3 min read

Loss

100 USDC of reserve, taken for 1 wei of collateral

Chain

Ethereum

Category

input-validation

Date

Sep 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: 42042-missing-call-to-computecollateralorlvlusdamount-in-levelmint. Standalone Foundry PoC and full write-up: 42042-missing-call-to-computecollateralorlvlusdamount-in-levelmint_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/input-validation/missing · vuln/logic/missing-check

Key info#

FieldValue
Loss100 USDC of reserve, taken for 1 wei of collateral
Vulnerable contractLevelMinting.mintDefault
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-09
Compilersolc 0.8.27, cancun, via IR
Bug classUser-supplied lvlUSD and collateral amounts are minted as-is

TL;DR#

mintDefault checks that the caller is the benefactor and then passes the order straight to _mint. It never calls computeCollateralOrlvlUSDAmount. A registered minter sets lvlusd_amount to 100 and collateral_amount to 1 wei, mints 100 unbacked lvlUSD, and redeems it against the 100 USDC another minter posted 1:1. The honest minter's later redeem is paid the remaining 1 wei.

The vulnerable code#

SOLIDITY
function mintDefault(Order memory order) external onlyMinterWhenEnabled {
    if (msg.sender != order.benefactor) revert MsgSenderIsNotBenefactor();
    _mint(order); // @> VULN: lvlusd_amount is minted without computeCollateralOrlvlUSDAmount
}

_mint pulls collateral_amount and mints lvlusd_amount. The fix recomputes the order first. At a 1:1 quote, 100 lvlUSD requires 100 collateral. Cantina recorded the fix in commit 532771c9.

Preconditions#

  • The caller is an enabled minter and is the order's benefactor.
  • Another minter has already minted 100 lvlUSD for 100 USDC. The contract holds that 100 USDC.
  • Redeem pays collateral 1:1 until the balance is gone.

Attack walkthrough#

  1. The order asks for 100 lvlUSD and offers 1 wei.
  2. mintDefault pulls 1 wei and mints 100 lvlUSD. The reserve is 100 USDC plus 1 wei.
  3. Redeeming 100 lvlUSD transfers 100 USDC to the caller.
  4. The honest minter redeems 100 lvlUSD and receives the leftover 1 wei.
  5. The caller's USDC balance went from 1 wei to 100 USDC.
  6. The control path recomputes collateral to 100 and reverts, because the caller does not have 100 USDC. The reserve stays 100.

Diagrams#

flowchart TD A["Reserve holds 100 USDC from a 1:1 mint"] --> B["Minter orders 100 lvlUSD for 1 wei"] B --> C["VULN: mintDefault skips the reprice"] C --> D["1 wei is pulled and 100 lvlUSD is minted"] D --> E["Redeem pays the 100 USDC reserve"] E --> F["Honest minter is left with 1 wei"] B --> G["Control sets collateral equal to the lvlUSD amount"] G --> H["Mint reverts and the 100 USDC stays"]

Impact#

The minter spends 1 wei and receives the 100 USDC that backed the earlier mint. That depositor's lvlUSD redeems for 1 wei. The missing reprice is what lets the amounts diverge from the 1:1 quote.

How to reproduce#

BASH
cd 42042-missing-call-to-computecollateralorlvlusdamount-in-levelmint_exp
forge test -vv

test_exploit_mints_unbacked_lvlusd_and_redeems_reserve asserts the caller ends with 100 USDC. test_control_recomputes_collateral asserts the fixed mint reverts and the reserve is unchanged.

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.