Critical Reentrancy Chain in a $40M DeFi Lending Protocol
How a multi-contract reentrancy path bypassed two existing audit reports and would have drained the protocol's entire liquidity reserve.
Engagement Breakdown
01 — Problem
The protocol had undergone two prior audits from well-known firms. Yet our pre-launch engagement was requested after an internal engineer noticed an unusual state ordering pattern in the collateral liquidation path. The client had $40M in locked liquidity preparing to go live on mainnet.
02 — Approach
We applied a three-track methodology: (1) automated scanning with Slither and Echidna fuzzing, (2) manual trace of every external call within the liquidation, borrow, and repay execution paths, and (3) formal modelling of the vault's state transitions using symbolic execution with Manticore. We paid specific attention to cross-contract interactions the previous audits had not modelled end-to-end.
03 — Technical Execution
We discovered a multi-hop reentrancy vector spanning three contracts: the Vault, the PriceOracle adapter, and an ERC-777 collateral token. During liquidation, the external call to the oracle's price feed triggered a callback into the Vault before balances were updated. An attacker could re-enter the liquidation function, drain the collateral reserve, and exit before the revert-on-underflow check fired. We built a full end-to-end exploit on a forked mainnet, draining 100% of available collateral in a single transaction.
04 — Impact
The vulnerability was remediated by introducing a re-entrancy guard and restructuring the state update order (checks-effects-interactions). Two additional high-severity issues — an unchecked return value on a fee transfer and a flash-loan-assisted oracle manipulation path — were patched before deployment. The protocol launched on schedule with zero post-deployment security incidents.
Tech Stack