Reproduced Exploit

LEND: the first borrow in a market compares collateral with zero

borrow asks getHypotheticalAccountLiquidityCollateral for the post-borrow debt and collateral, then ignores that debt. It builds borrowAmount from the caller's stored borrow index. On the first borrow in the market the index is 0, so borrowAmount is 0. require(collateral >= borrowAmount) is require…

May 2025•Ethereum•logic•3 min read

Loss

1000 lUSD borrowed against 100 of collateral value

Chain

Ethereum

Category

logic

Date

May 2025

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: 58396-h-27-incorrect-collateral-check-logic-in-coreroutersolborrow. Standalone Foundry PoC and full write-up: 58396-h-27-incorrect-collateral-check-logic-in-coreroutersolborrow_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/wrong-condition · vuln/logic/missing-check

Key info#

FieldValue
Loss1000 lUSD borrowed against 100 of collateral value
Vulnerable contractCoreRouter.borrow
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2025-05
Compilersolc 0.8.27, cancun, via IR
Bug classSolvency check uses a borrow amount that is 0 on the first borrow

TL;DR#

borrow asks getHypotheticalAccountLiquidityCollateral for the post-borrow debt and collateral, then ignores that debt. It builds borrowAmount from the caller's stored borrow index. On the first borrow in the market the index is 0, so borrowAmount is 0. require(collateral >= borrowAmount) is require(100 >= 0). The router then transfers 1000 lUSD out of the suppliers' reserve.

The vulnerable code#

SOLIDITY
uint256 borrowAmount = currentBorrow.borrowIndex != 0
    ? ((borrowed * LTokenInterface(_lToken).borrowIndex()) / currentBorrow.borrowIndex)
    : 0;

require(collateral >= borrowAmount, "Insufficient collateral"); // @> VULN: first borrow sets borrowAmount to 0, so collateral >= 0 always passes

borrowed in this run is 1000 and collateral is 100. The check that matches the liquidity helper is require(collateral >= borrowed).

Preconditions#

  • The caller has no borrow record in this market, so borrowIndex is 0.
  • Collateral value is 100. The requested borrow prices to 1000.
  • The lToken reserve holds at least 1000 of underlying, funded by other suppliers.

Attack walkthrough#

  1. Record 100 of collateral value.
  2. Call borrow(1000). The hypothetical result is debt 1000 and collateral 100.
  3. The stored borrow index is 0, so the amount compared with collateral is 0.
  4. 100 >= 0 passes.
  5. The lToken pays 1000 underlying to the router and the router forwards it to the caller. The reserve falls from 2000 to 1000.
  6. The control compares collateral with the hypothetical debt and reverts. The reserve stays 2000.

Diagrams#

flowchart TD A["Caller has 100 collateral and no borrow in this market"] --> B["borrow 1000 asks for hypothetical liquidity"] B --> C["Helper returns debt 1000 and collateral 100"] C --> D["VULN: borrowIndex is 0 so the checked amount is 0"] D --> E["100 is at least 0 and the require passes"] E --> F["1000 lUSD leaves the suppliers reserve"] C --> G["Control requires collateral at least the hypothetical debt"] G --> H["100 is below 1000 and the borrow reverts"]

Impact#

A first-time borrower in a market receives 1000 lUSD while posting collateral the protocol itself values at 100. The extra 900 is bad debt against the suppliers who funded the reserve. The same call reverts if the check uses the hypothetical debt.

How to reproduce#

BASH
cd 58396-h-27-incorrect-collateral-check-logic-in-coreroutersolborrow_exp
forge test -vv

test_exploit_first_borrow_bypasses_collateral_check asserts 1000 received, a zeroed check, and 1000 left in a reserve that started at 2000. test_control_compare_hypothetical_debt_reverts asserts the fixed router reverts and the reserve is intact.

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.