Status DataClose notification

DeFi Security: Risks, Real Exploits, and Best Practices for Protocol Teams

Andrii Stepanov
Andrii StepanovSecurity Researcher
9 Minutes ReadPublished: 26 Jul 2023

Updated on November 2nd, 2026

Web3 lost about $4 billion to hacks and exploits in 2025, according to the Hacken 2025 Yearly Security Report. More than $2.1 billion of that came from operational security failures, and $512 million was exploited in DeFi protocols.

2026 has made the pattern sharper. In Q2 alone, attackers took $763.9 million across 67 incidents. Smart contract bugs showed up in 44 of those incidents but accounted for only about 11% of the losses. The other 88% came from compromised keys, signers, and infrastructure.

That split defines DeFi security today. Code bugs are frequent; key and process failures are expensive. A protocol that only audits its contracts is defending against the cheaper half of the problem.

How DeFi Protocols Get Hacked

Almost every DeFi exploit falls into one of eight attack vectors. Knowing which ones apply to your architecture tells you where to spend your security budget.

1. Smart contract logic bugs

A flaw in the code itself: reentrancy, unsafe external calls, delegatecall to untrusted contracts, missing access checks, or math and rounding errors. These are the most common root causes by incident count. They can still be catastrophic: in May 2025, a single incorrect value in an overflow check let an attacker drain about $223 million from Cetus, the largest DEX on Sui.

Most smart contract vulnerabilities follow recognizable patterns, which is why experienced auditors and researchers catch them before attackers do.

Main controls: secure coding patterns, deep testing, and independent audits.

2. Oracle and price manipulation

Lending markets, perpetuals, and vaults all depend on prices. If a protocol reads a spot price from a single thin pool, an attacker can move that price within one transaction, usually with borrowed capital, then borrow or withdraw against the fake value. Most flash loan attacks follow exactly this pattern.

Main controls: manipulation-resistant oracle design and sanity bounds on prices.

3. Access control and private key compromise

Admin keys, multisig signers, and deployer wallets control upgrades, parameters, and treasury funds. Attackers increasingly skip the code and go after the people holding those keys, through malware, fake job offers, or long-running social engineering. This is now the largest category of losses by value, in DeFi and in centralized platforms alike, as the Binance hack showed.

Main controls: hardened multisig setups, timelocks, and signer operational security.

4. Cross-chain bridges and messaging

Bridges hold large pools of locked assets and rely on validators or verifiers to confirm messages between chains. If that verification can be forged or the validator set is small, an attacker can mint or release assets that were never deposited. Bridge incidents produce some of the largest single losses in DeFi, and most of them trace back to a handful of design choices in cross-chain bridge security.

Main controls: multiple independent verifiers, rate limits, and audits of bridge configuration, not just bridge code.

5. Governance attacks

On-chain governance lets token holders change protocol logic. If voting power can be borrowed and used in the same block, or proposals execute without a delay, an attacker can buy a majority for a few seconds and vote through a malicious proposal.

Main controls: snapshot-based voting power, voting delays, and time-locked execution.

6. Front-end and supply-chain attacks

The contracts can be flawless, but the website users interact with may not be. Compromised DNS, injected front-end scripts, or a poisoned dependency can trick users into signing malicious approvals that look legitimate.

Main controls: front-end integrity monitoring, locked-down DNS and infrastructure accounts, and pinned dependencies.

7. MEV and front-running

Pending transactions are public. Bots can see a large swap in the mempool and place trades before and after it (a sandwich attack), extracting value from users. On decentralized exchanges, this shows up as worse execution rather than a headline hack, but it is a real cost to users.

Main controls: slippage limits, private transaction routing, and commit-reveal schemes where ordering matters.

8. Insider risk and rug pulls

If a small team controls liquidity, upgrade rights, or minting, users depend entirely on that team's intentions. A rug pull uses that control to drain the protocol.

Main controls: time-locked withdrawals and upgrades, transparent ownership, and distributed control of critical functions.

Yield farming and liquidity pool risks

Yield farming adds risks on top of the vectors above. Farms reward users with the protocol's own token, so high advertised yields can collapse as emissions dilute the token's value. Vaults that route deposits through several strategies inherit the risks of every protocol they touch: a failure in one underlying market can spread to the vault and its depositors. Stablecoin farms carry depeg risk in addition to smart contract risk.

The early yield farming exploits were textbook cases of the first two vectors. Harvest Finance (about $34 million in 2020) was drained through flash-loan price manipulation, and dForce's Lendf.Me (about $25 million in 2020) through reentrancy. Impermanent loss is also often listed as a yield farming risk, but it is market risk, not a security failure.

The same composability affects DeFi lending protocols, which often accept farm and vault tokens as collateral.

Major DeFi Exploits, 2016–2026

Ten years of DeFi hacks show a clear shift: early losses came from code bugs, while the largest recent ones came from compromised keys, signers, and verification infrastructure.

Date Protocol Approx. loss Root cause Attack vector

April 2026

KelpDAO

$292M

Forged cross-chain message accepted by a bridge configured with a single verifier

Bridge

April 2026

Drift Protocol

$280–285M

Six-month social engineering campaign against Security Council signers, combined with oracle manipulation of a fake collateral token

Key compromise, oracle

May 2025

Cetus

$223M ($162M frozen)

Flawed overflow check in a shared math library

Smart contract bug

October 2024

Radiant Capital

$50–53M

Malware on signers' devices; a 3-of-11 multisig meant only three devices had to be compromised

Key compromise

July 2023

Curve pools (Vyper bug)

~$69M before recoveries

Broken reentrancy locks in Vyper compiler versions 0.2.15, 0.2.16 and 0.3.0

Smart contract bug

March 2023

Euler Finance

$197M

Missing solvency check in a donation function; recoverable funds later returned

Smart contract bug

August 2022

Nomad

~$190M

An upgrade set the trusted root to zero, so every message passed verification

Bridge

April 2022

Beanstalk

$182M (attacker kept ~$76–80M)

Flash-loaned voting power passed a malicious proposal through emergency execution

Governance

March 2022

Ronin

~$625M

Five of nine validator keys compromised

Bridge, key compromise

December 2021

BadgerDAO

~$120M

Compromised Cloudflare API key used to inject a malicious script into the front end

Front end

October 2021

Cream Finance

~$130M

Flash loan used to inflate the price of a collateral token

Oracle

November 2020

Pickle Finance

~$20M

Fake "evil jar" contracts passed to an unvalidated swap function

Smart contract bug

October 2020

Harvest Finance

$34M drained ($24M attacker profit)

Flash-loan price manipulation of a Curve pool

Oracle

April 2020

dForce (Lendf.Me)

~$25M

ERC-777 reentrancy; funds later returned

Smart contract bug

February 2020

bZx

~$954K across two attacks

Flash loans used to manipulate prices

Oracle

June 2016

The DAO

~$60M (3.6M ETH)

Reentrancy

Smart contract bug

Two lessons stand out. First, three of the five largest losses since 2022 (Ronin, KelpDAO and Drift) came from keys, verifiers and social engineering rather than from flaws in contract code, so a code audit alone would not have prevented them. Second, the response matters as much as the prevention. Cetus recovered most of its funds because validators froze them within hours, and Radiant Capital, which never recovered from its 2024 breach, announced it was winding down in 2026.

DeFi Security Best Practices

DeFi security best practices work best as a lifecycle, not a checklist you complete once before launch. Each practice below maps to one or more of the attack vectors above.

Before launch: build it secure

  1. Threat-model the protocol and write down its invariants. List what must always be true (total deposits cover total claims, only governance can change fees, prices stay within bounds) and who could break each rule. Invariants become your test targets and give auditors a clear map of what matters.
  2. Use proven secure coding patterns. Follow checks-effects-interactions, add reentrancy guards to functions that move value, and build on well-tested libraries such as OpenZeppelin instead of rewriting standard components. Never delegatecall into untrusted contracts. Put explicit access control on every privileged function. Treat unchecked blocks and custom math libraries with extra suspicion: the Cetus exploit came from one wrong value in an overflow check.
  3. Test beyond unit tests. Add fuzzing and invariant tests that throw random sequences of calls at the protocol. Run fork tests against real mainnet state and simulate attacks, including flash-loan-funded price manipulation. For core math and accounting, consider formal verification.
  4. Get independent audits, and more than one for high-value code. Different reviewers find different bugs. A smart contract audit covers the code in scope at a point in time; a DualDefense audit adds a crowdsourced layer of researchers on top of a third-party audit to catch what a single team misses.
  5. Launch in stages. Run a public testnet with a bug bounty before mainnet, then cap TVL in the first weeks of production and raise limits as the code proves itself.

At deployment: limit what any single failure can do

  1. Harden every privileged key. Put admin roles behind a multisig with independent, hardware-backed signers. Choose a threshold that matters: Radiant Capital's 3-of-11 setup meant attackers only needed to compromise three devices. Signers should decode and verify every transaction independently rather than trusting what a single interface shows, and should never sign transactions in advance. Drift's attackers used pre-signed transactions obtained through social engineering.
  2. Put timelocks on upgrades and parameter changes. A delay of 24–72 hours gives users, monitors, and researchers time to spot a malicious change. Treat upgradeability as a risk to control, not just a way to fix bugs later.
  3. Design oracles to resist manipulation. Use decentralized price feeds, combine multiple sources, prefer time-weighted prices over spot prices, and reject values outside sanity bounds. Be especially careful when listing new collateral: in the Drift attack, wash trading made a worthless token look like it was worth $1.
  4. Never rely on a single verifier for cross-chain messages. Configure bridges with multiple independent verifiers and audit the configuration, not only the bridge contracts. KelpDAO's bridge accepted a forged message because one verifier was the only check.
  5. Add rate limits and circuit breakers. Withdrawal caps per block or per hour turn a total drain into a partial loss. A pause function controlled by a separate guardian role lets the team stop an attack in progress.
  6. Harden governance. Calculate voting power from a snapshot taken before a proposal, add a voting delay, and time-lock execution so borrowed tokens cannot pass a proposal in a single block.

After launch: assume something will be missed

  1. Run a continuous bug bounty sized to your TVL. Audits are snapshots; a bug bounty program keeps researchers testing every release. Payouts for critical findings need to be large enough that reporting beats exploiting. The cost of a bug bounty program depends mostly on scope and reward levels, and is small next to a single exploit.
  2. Monitor on-chain activity in real time. Watch admin actions, large or unusual outflows, oracle deviations, and new contract interactions with your protocol. Route alerts to people who are authorized to pause the protocol, at any hour.
  3. Write and rehearse an incident response plan. Decide in advance who can pause what, who contacts exchanges and bridges to freeze funds, and who speaks publicly. Keep contacts for SEAL 911, the security community's emergency response group, ready. The Cetus recovery showed how much a fast response can save.
  4. Treat operational security as part of protocol security. Signers should use dedicated devices for signing. Train contributors to recognize long-running social engineering, including fake job offers, fake investors, and contacts made at conferences. Lock down DNS and hosting accounts, and pin front-end dependencies.
  5. Re-audit after every significant upgrade. New code, new integrations, and new collateral types change the attack surface. A protocol is only as secure as its latest unreviewed change.

How To Measure DeFi Protocol Security

There is no single DeFi security score, but seven checks cover most of the risk. Use them on your own protocol, or on any protocol you plan to integrate with or accept as collateral.

Criterion What good looks like Red flag

Audit coverage

All deployed contracts audited, including the latest version, by more than one reviewer

Audit covers an older version, or only part of the code

Bug bounty

Active program with critical payouts scaled to TVL

No program, or a maximum payout far below the funds at risk

Admin key setup

Multisig with a meaningful threshold, independent signers, published configuration

Single admin key, or a low threshold across many signers

Timelocks

Upgrades and parameter changes delayed, with the delay visible on-chain

Owner can upgrade or change parameters instantly

Oracle design

Decentralized or multi-source feeds with sanity bounds

Spot price from a single pool

Monitoring and response

Real-time monitoring, a pause mechanism, and a public record of past incidents

No pause function, or no history of disclosed issues

Time in production

Long record without incidents at meaningful TVL

New code holding large deposits from day one

A protocol that fails two or more of these checks carries risk that no amount of advertised yield can justify.

DeFi Security Tools

Tools catch whole classes of bugs cheaply, but none of them understands your protocol's business logic. Use them to clear the obvious issues so human reviewers can focus on what tools miss.

Category What it catches Open-source examples

Static analysis

Known vulnerability patterns, unsafe calls, missing checks

Slither

Fuzzing and invariant testing

Sequences of calls that break your stated invariants

Echidna, Foundry

Formal verification

Proves that core math and accounting hold for all inputs

Halmos

On-chain monitoring

Abnormal flows, admin actions, and oracle deviations in production

Custom alerting on your indexer or node

Crowdsourced security

Logic and economic flaws tools cannot model

Audits and bug bounties with independent researchers

Business-logic and economic bugs need people who think like attackers, which is why mature protocols combine automated tooling with audits and an ongoing bug bounty.

Conclusion

DeFi security has shifted. Code bugs still cause the most incidents, but the largest losses now come from compromised keys, signers, and verification infrastructure: in Q2 2026, they accounted for 88% of stolen funds. A clean audit report says little about how a protocol will hold up against an attacker who targets its people instead of its code.

The protocols that survive treat security as a lifecycle. They design and test against written invariants before launch, limit what any single key, verifier, or transaction can do at deployment, and keep researchers, monitoring, and a rehearsed response plan in place once real money is at stake. No single layer is enough on its own, and attackers look for the one that is missing.

A practical place to start is the seven-point scorecard above: run your own protocol through it, then close the gaps in order of how much each failure would cost.

FAQ

What are the risks of DeFi?

The main risks are smart contract bugs, oracle manipulation, compromised admin keys, bridge failures, governance attacks, front-end compromises, and insider rug pulls. Users also face market risks such as stablecoin depegs and impermanent loss, which are not security failures but can still cause losses.

What are the risks of yield farming?

Yield farming carries all the usual DeFi security risks plus a few of its own: reward tokens that lose value as emissions grow, vault strategies that pass on the risks of every protocol they use, and depeg risk in stablecoin farms. Early yield farming exploits mostly came from flash-loan price manipulation and reentrancy.

What is the most common cause of DeFi hacks?

By number of incidents, smart contract bugs are the most common cause. By value, compromised keys, signers, and infrastructure dominate: in Q2 2026 they accounted for 88% of stolen funds, according to Hacken.

How do you improve DeFi security?

Start with secure design and thorough testing, get independent audits, and harden every privileged key with multisig and timelocks. After launch, run a continuous bug bounty, monitor the protocol in real time, and keep a rehearsed incident response plan.

Is a smart contract audit enough to secure a DeFi protocol?

No. An audit reviews a specific version of the code at one point in time. It does not cover later upgrades, operational security, key management, or bridge configuration, which is where most of the largest recent losses came from.

How much should a DeFi protocol pay in bug bounties?

Critical rewards should be large enough that reporting a vulnerability is clearly more attractive than exploiting it, so they should scale with the value at risk. Lower-severity rewards can stay modest.

Share article:

More topics: