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…
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
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: 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-registrymirror.
Vulnerability classes:
vuln/logic/wrong-condition·vuln/logic/missing-check
Key info#
| Field | Value |
|---|---|
| Loss | 1000 lUSD borrowed against 100 of collateral value |
| Vulnerable contract | CoreRouter.borrow |
| Attacker EOA | 0x1111111111111111111111111111111111111111 |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Ethereum model · block 0 · 2025-05 |
| Compiler | solc 0.8.27, cancun, via IR |
| Bug class | Solvency 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#
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
borrowIndexis 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#
- Record 100 of collateral value.
- Call
borrow(1000). The hypothetical result is debt 1000 and collateral 100. - The stored borrow index is 0, so the amount compared with collateral is 0.
100 >= 0passes.- The lToken pays 1000 underlying to the router and the router forwards it to the caller. The reserve falls from 2000 to 1000.
- The control compares collateral with the hypothetical debt and reverts. The reserve stays 2000.
Diagrams#
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#
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#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/58396-h-27-incorrect-collateral-check-logic-in-coreroutersolborrow.md
- Sherlock issue 1010: https://github.com/sherlock-audit/2025-05-lend-audit-contest-judging/issues/1010
- Borrow: https://github.com/sherlock-audit/2025-05-lend-audit-contest/blob/main/Lend-V2/src/LayerZero/CoreRouter.sol#L153
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 58396-h-27-incorrect-collateral-check-logic-in-coreroutersolborrow_exp (evm-hack-registry mirror).
- AuditVault finding: 58396-h-27-incorrect-collateral-check-logic-in-coreroutersolborrow.
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.