Anatomy of a DeFi Exploit: From Flash Loan to Cash-Out

Anatomy of a DeFi Exploit: From Flash Loan to Cash-Out

A DeFi exploit rarely looks like a heist in the moment. It looks like a sequence of perfectly valid transactions executed faster than any human could react. By the time a protocol notices its balances are wrong, the attacker is already several steps into moving the funds. Understanding the anatomy of a DeFi exploit — each stage, in order — is the first step toward both preventing one and chasing down the proceeds afterward.

What follows is an illustrative composite: a hypothetical attack assembled from common patterns, not a description of any specific real incident. The mechanics, however, are representative of how these attacks actually unfold.

Stage 1: The flash loan

Most large exploits begin with capital the attacker does not own. A flash loan lets anyone borrow an enormous sum with no collateral, provided the loan is repaid within the same transaction. If repayment fails, the entire transaction reverts as if it never happened.

This gives an attacker temporary access to far more capital than they hold — often millions of dollars of liquidity — purely to manufacture the conditions for the next stage. The flash loan itself is not the exploit. It is the lever.

Stage 2: The manipulation

With borrowed capital in hand, the attacker bends the protocol's logic. The exact mechanism varies, but three families dominate:

  • Oracle manipulation. The borrowed funds are used to skew the price feed a protocol relies on — for example, dumping into a thin liquidity pool so the protocol misprices an asset, then borrowing or redeeming against the distorted price.
  • Reentrancy. A malicious contract re-enters a vulnerable function before its balances update, draining more than the logic intended on each pass.
  • Governance attack. The attacker amasses temporary voting power and pushes through a proposal that redirects funds or grants malicious permissions.

This is the stage an audit is meant to catch. But audits are point-in-time reviews of code, and manipulation happens at runtime against live liquidity and live prices — which is precisely why protocols need automated circuit breakers in addition to audits.

Stage 3: Extraction

Once the protocol is mispriced or its guardrails are bypassed, the attacker extracts value and repays the flash loan — all atomically. The illustrative sequence below shows the shape of a single exploit transaction:

1. flashLoan(50,000,000 USDC)        // borrow, no collateral
2. swapIntoPool(USDC -> ASSET)        // distort the price feed
3. borrowAgainst(ASSET, inflated)     // draw out more than deposited
4. repay(50,000,000 USDC + fee)       // close the flash loan
5. keep(profit -> attacker wallet)    // net proceeds retained

From the outside this is one transaction that succeeds. The protocol's accounting is now wrong, and the difference sits in the attacker's wallet.

Stage 4: Laundering

Holding stolen funds in one wallet is risky, so the attacker immediately works to obscure the trail. This is where the attack stops being a smart-contract problem and becomes a tracing problem. Typical laundering moves include:

  • Splitting the proceeds across many fresh wallets to fragment the balance.
  • Bridging the funds to other chains, breaking the trail for anyone watching only the chain where the exploit happened.
  • Mixing through a tumbler to sever the link between deposit and withdrawal.
  • Swapping assets repeatedly to change what is being followed.

The bridge step is the critical one. Each cross-chain hop is designed to be a dead end for single-chain analysis.

Stage 5: The cash-out

Laundered funds are only useful once converted to something spendable. The final stage is the off-ramp: depositing into a centralized exchange or other service to convert and withdraw. Ironically, this is often the most traceable moment — regulated venues collect identity information, so a deposit attributed to a known exchange is a lead an investigator or counsel can act on.

Why cross-chain tracing is the counter

Every laundering tactic above assumes the funds become unfollowable once they leave the chain of origin. Cross-chain tracing removes that assumption.

Noxos follows exploit proceeds automatically. Pointed at the attacker's wallet, it walks the transfers outward, and when funds reach a bridge it detects the bridge, resolves the destination, and continues the trace on the next chain — in one connected graph spanning up to 17 blockchains and the major cross-chain bridges between them. Splitting and bridging no longer break the trail; they just become more nodes in the map. The full method is covered in our guide to cross-chain funds tracing.

Because the traversal is deterministic and every step is written to an immutable per-case audit log, the reconstruction is reproducible and defensible — not just an explanation of what happened, but evidence of it. For a broader view of attacks as they emerge, see our latest crypto hacks and exploits tracker.

From incident to evidence

A DeFi exploit moves in minutes; the laundering that follows can span chains within the hour. Whether you are defending a protocol or recovering funds, the answer is the same: follow the money across every chain it touches and document the path. Run the trace on Noxos and turn an exploit into a graph you can act on.