In April 2022, an attacker borrowed roughly $1 billion in a single flash loan transaction, used it to temporarily seize voting control over a protocol called Beanstalk Farms, and voted to drain its treasury, walking away with $182 million before the loan was ever repaid. That entire sequence, borrow, vote, drain, repay, happened within a single blockchain transaction, illustrating just how fast and how large these exploits can move once the right combination of flaws lines up. Understanding how something like that is even possible requires understanding the actual mechanisms behind smart contract exploits, not just the dollar figures headlines report. Each smart contract exploit explained below follows a pattern like that one.
Smart Contract Exploit Explained: What “Exploit” Actually Means
An exploit isn’t a stolen password or a compromised account, it’s code behaving exactly as written but in a way its creators never intended, taking advantage of a genuine flaw in the contract’s logic rather than breaking in through some external door. This distinction matters enormously for how you think about DeFi risk: there’s no lock to pick or password to guess, the vulnerability was there in the contract’s own published, often publicly viewable code the entire time, waiting for someone to notice it before the developers did. This is why “the code is the law” cuts both ways: a contract executes precisely what it says, including the parts nobody meant to include.
Reentrancy: Draining Funds Through Repeated Calls
Curve Finance Review: Stablecoin Swaps Explained covers a real, detailed example of this mechanism: a flaw in Vyper’s compiler broke reentrancy protection, letting an attacker repeatedly withdraw funds before the contract could register that funds had already been sent, roughly $70 million taken across several protocols in July 2023. The pattern generalizes well beyond that specific incident: any function that sends funds out before fully updating its own internal accounting creates a window an attacker can potentially exploit repeatedly within that same brief window.
Oracle Manipulation: Feeding the Contract Bad Information
A smart contract often relies on a price oracle to know an asset’s current value. If that oracle can be manipulated, tricked into reporting a false price, a contract can be tricked into approving a bad trade or an oversized loan. The underlying weakness is usually structural: a protocol relying on a single, thin price source, easily moved with a large enough trade, rather than an aggregated feed drawing from multiple independent sources that would be far harder to manipulate simultaneously. Chainalysis estimated DeFi protocols lost $386.2 million across 41 separate oracle manipulation attacks in a single year. Aave’s own March 2026 incident, covered in its full review, was a contained example of exactly this category.
Access Control Flaws: Missing Permission Checks
Uniswap Review: Features, Fees, and Is It Safe? covers a real example: the Cork Protocol hack exploited a missing access control check in a custom hook, letting an attacker call a function that should have been restricted to the protocol’s own core contract, tricking it into crediting funds that were never actually deposited. This category is often the most preventable in hindsight, a single missing line of code checking who’s actually allowed to call a function, yet it remains one of the more common root causes across major exploits, precisely because increasingly complex, modular protocols create more surface area for a single check to be overlooked somewhere.
| Exploit Type | Core Mechanism |
|---|---|
| Reentrancy | Repeated withdrawal before balance updates |
| Oracle manipulation | Tricking the contract’s price source |
| Access control flaw | Missing permission check on a sensitive function |
| Flash loan attack | Massive temporary capital amplifying another flaw |
Flash Loans: The Amplifier, Not the Vulnerability
Flash loans themselves aren’t a flaw, they’re a legitimate tool. The problem is what they enable: borrowing enormous, uncollateralized sums for a single transaction gives an attacker temporary capital large enough to manipulate a price, sway a governance vote, or drain a pool, then repay the loan before the transaction ends, all in one atomic step. The Beanstalk case is the clearest illustration: the underlying flaw was a governance system that let a large enough temporary token holder push through a proposal instantly, the flash loan just supplied the scale needed to exploit it. Beanstalk’s governance system allowed a proposal to be voted on and executed within a very short window, not accounting for the possibility that voting power itself could be temporarily, massively inflated within that same window through borrowed capital. The lesson generalizes: any system where temporary control, voting power, price influence, or collateral value, can be borrowed rather than genuinely earned or held, carries this same underlying exposure, regardless of how sound the rest of its code might be.
Understanding these mechanisms helps you evaluate real risk. Building that into an actual strategy is the next step.
The Crypto/DeFi Trading Course covers how to size positions realistically against genuine, documented exploit categories like these.
Why These Keep Happening Despite Audits
Audits check for known categories of vulnerability against a fixed snapshot of code, they can’t guarantee every possible interaction across an increasingly complex, interconnected DeFi ecosystem has been anticipated. This is also why the size and reputation of an audit firm, while genuinely meaningful, isn’t a perfect predictor either, even the most thorough audit is bounded by the specific code and scenarios its reviewers actually considered, not every conceivable future interaction a protocol might later be composed with. New features, new integrations, and new attack techniques all continue emerging faster than any single audit can permanently rule out.
What This Means for You as a User
How to Evaluate Any DeFi Protocol Before Using It covers the practical checklist; understanding these specific mechanisms helps you ask sharper questions, does this protocol rely on a single price source, has this specific feature been independently audited, rather than accepting a general “it’s audited” reassurance at face value. It’s also worth recognizing that no individual user can realistically audit a protocol’s code themselves; the more practical, achievable goal is recognizing the pattern well enough to ask informed questions and weigh a platform’s track record honestly, not becoming a security researcher yourself.
Frequently Asked Questions
Is a smart contract exploit the same thing as a hack of an exchange?
No. An exchange hack typically involves compromising credentials or centralized infrastructure; a smart contract exploit involves the contract’s own code executing exactly as written, just in an unintended, damaging way.
Can an audited protocol still be exploited?
Yes. An audit reduces the odds of a known vulnerability class slipping through but can’t guarantee protection against every possible interaction, especially as new features and integrations are added after the audit.
Are flash loans themselves dangerous to use?
Using a flash loan yourself, for legitimate arbitrage or refinancing, carries no inherent danger. The risk covered here is a protocol’s own vulnerability being exploited using someone else’s flash loan, not the tool itself.
What happened to Beanstalk Farms after the attack?
The protocol’s treasury was drained through the manipulated governance vote, a stark illustration of how quickly a large enough temporary capital advantage can override a system’s intended safeguards.
Do all DeFi protocols use the same governance voting speed Beanstalk did?
No, many protocols have since adopted longer voting periods, timelocks, or other delays specifically to prevent the same kind of instant, flash-loan-funded governance takeover.
How can I tell if a protocol is vulnerable to oracle manipulation specifically?
Check whether it relies on a single price source versus multiple, aggregated oracles; a protocol depending on one thin, easily moved price feed carries meaningfully more of this specific risk.
None of these mechanisms are mysterious once named clearly: repeated calls before a balance updates, a manipulated price feed, a missing permission check, or borrowed capital amplifying any of the above. Recognizing the pattern is what turns a vague fear of “hacks” into a specific, genuinely useful set of questions worth asking before trusting a protocol with real funds. With the smart contract exploit explained at this level, you can read hack post-mortems and understand what actually went wrong.
Ready to evaluate DeFi risk with real, specific understanding? The Crypto/DeFi Trading Course helps you build exactly that.
Prefer to learn from a book, at your own pace? The Crypto Book Series covers this in more depth. If you’re new to crypto, start with Book 1, then work through the series as you go.
Trying to understand a specific protocol’s exploit history? Join DavitoFinance Pro on Telegram, free, and ask people who track this closely.






