A reentrancy attack tricks a smart contract into paying out again before it has recorded the first payment.
This guide is for students, new developers and anyone curious about how crypto projects lose money to bugs. You do not need to write code to follow it. If you hold crypto in an app or invest in a project, this bug is one reason audits matter.
In short
- A smart contract is a program on a blockchain that can hold and send money.
- Reentrancy happens when a contract sends money first and updates its records second. The receiver can call back in during that gap and ask again.
- In 2016 this kind of bug let an attacker drain over 3.6 million ETH from a project called The DAO.[4]
- The usual fix is simple to say: update the records before sending anything, and add a lock that blocks a second call.
What you will learn
- Explain reentrancy in one sentence.
- Spot the wrong order of steps that causes it.
- Explain what happened in the DAO hack and why it still matters.
- Ask a project the right questions about how it guards against this bug.
- Self-running program (smart contract)
- code stored on a blockchain that follows its rules whenever someone uses it.
- Calling back in (reentrancy)
- when another program gets back into a contract before the contract has finished its first job.
- Shared record (blockchain)
- a public list of transactions that many computers keep copies of.
What is a reentrancy attack?
Think of a vending machine that gives you your drink before it takes the credit off your balance. While the drink is still dropping, you press the button again. The machine still thinks you have credit, so it gives you another drink.
A smart contract is a program on a blockchain that can hold and send money. Many contracts keep a list of how much each person has paid in. When you ask for your money back, the contract should do three things in a sensible order.
- Check that you have enough.
- Take the amount off your balance.
- Send you the money.
The bug happens when steps 2 and 3 swap places. When a contract sends money to another program, that program gets a moment to run its own code.[1] A hostile program can use that moment to call the contract again. The balance has not been cut yet, so the check passes again. This is reentrancy: getting back in before the first request has finished.
Where the comparison stops working: a real vending machine runs out of drinks or jams. A flawed contract can repeat the loop many times in a single transaction, until its funds run low.
Why does it matter?
Smart contracts often hold large sums, and the code is public for anyone to study. A single wrong order of steps can let one caller take far more than they paid in. A respected open security project still lists reentrancy among its top ten smart contract risks in 2026.[2]
If you are learning to write smart contracts
What could happen: your first contract sends money before it updates the balance, and a test attacker drains it.
Check this: in every function that sends money, make sure the records change first.
If you put money into crypto projects
What could happen: a project you use is drained, and your funds go with it.
Check this: look for a published audit from an independent reviewer before you deposit.
If you are thinking about a security career
What could happen: you meet this bug in your first code review and need to explain it clearly.
Check this: practise spotting the wrong order in small sample contracts.
What does it look like?
Here is a made-up contract written in plain words, not real code. It is a shared piggy bank that pays people back.
Example only. All values are made up.
Piggy Bank contract (EXAMPLE) When someone asks to withdraw an amount: check their balance is at least the amount (1) send the amount to the caller (2) take the amount off their balance (3) Balance for caller 0x0000-EXAMPLE: 1 FAKE-coin
- The check is correct on its own.
- Money goes out while the record still shows the full balance. The caller's program can run here and ask again.
- The balance is cut last, after the caller may have asked many times.
Why this is risky: each repeat request passes the check in step 1, because step 3 has not happened yet. One caller with 1 coin could take far more than 1 coin.
The safer way: swap steps 2 and 3. Check first, update the balance second, and send money last. Developers call this order "checks, effects, interactions".[1] Many teams also add a lock, called a reentrancy guard, that refuses a second call into the same function until the first one has finished.[2]
How does it work?
Here is the attack in plain steps, from the defender's point of view.
- Money goes in. The attacker's program pays a small amount into the contract, so it has a balance.
- A withdrawal starts. The program asks for its money back. The contract checks the balance, and it is fine.
- Control passes over. The contract sends the money. Sending money to another program lets that program run its own code.[1]
- The program calls back in. Before the first withdrawal has finished, it asks again. The balance still looks full.[2]
- The loop repeats. Each round pays out again, until the contract runs low or a limit stops it. Only then do the balance updates run.


The story of the DAO hack
The DAO was an early project on the Ethereum blockchain that pooled money from many investors. In June 2016, an attacker found a flaw in it. Ethereum's co-founder described it as a "recursive calling" bug: the attacker called a function inside itself, collecting ether many times in one transaction.[3] He also said the flaw was in The DAO, not in Ethereum itself.[3]
The contract was drained of over 3.6 million ETH. On 20 July 2016 the Ethereum network made a rule change, called a hard fork. It moved the funds into a new contract so holders could reclaim them. Some miners refused the change and carried on with the old chain, which became Ethereum Classic.[4]
The lesson has lasted. OWASP's 2026 list names a 2025 incident with an estimated loss of about 42 million US dollars. There, a transfer let an attacker re-enter a contract and change its accounting.[2]
A worked example
Freya Sorensen is a student on a coding course. For her end of term project she writes a small savings contract. Classmates can pay in test coins and take them out later.
Her withdraw function looks fine to her. It checks the balance, sends the coins, then sets the balance to zero. All her tests pass, because each test asks for money once.
Before she shares it, her mentor, Marek Tanaka, asks one question. "What if the person you pay is a program, and it asks again while you are still paying?"
Freya draws the steps on paper. She sees the gap between sending the coins and setting the balance to zero. A second request in that gap would still see the old balance.
She swaps the two lines, so the balance is set to zero before the coins go out. She also adds a reentrancy guard from a well-known library, so the function refuses a second call until the first has finished. Then she writes a new test that tries to call back in during a withdrawal. It now fails, as it should.
Marek suggests one more habit. Each time she writes a function that sends money, she asks the same question before she moves on. Freya adds a line to her checklist: "Records first, money last."
Her contract only ever held test coins. But the habit is the same one that protects real projects.
Myths and mistakes
| What people think | What is true |
|---|---|
| Reentrancy is an old bug that nobody makes any more. | It is still on OWASP's 2026 list, with a 2025 incident named as an example. |
| If my tests pass, the contract is safe. | Normal tests ask once. Add tests that try to call back in during a payment. |
| Only functions that send money can be re-entered. | OWASP notes it can also spread across different functions and different contracts that share records. |
| A guard on one function is enough. | Check every function that calls out to other programs, and keep the records-first order as well. |
| The blockchain itself was hacked in 2016. | The flaw was in The DAO's own contract, not in Ethereum. |
What can I do this week?
- Read the reentrancy part of the Solidity security guide. It is linked in the sources below.
- Find each part of your project that sends money or calls another contract.
- Check that each one updates its records before it sends anything.
- Add a test that tries to call back in during a payment.
- Ask any project you invest in whether an independent audit has been published.
Checklist
- I can explain reentrancy in one sentence.
- Every function that sends money checks first, updates second and sends last.
- Functions that send money or call other contracts have a reentrancy guard.
- I have tests that try to call back in during a payment.
- I review calls between functions and between contracts, not just single functions.
- An independent review is planned before real money goes in.
Common questions
Why is it called reentrancy?
Because the attacker re-enters the contract. The first request is still running when a second one comes in through the same door. The contract treats the second request as fresh, even though its records are out of date, and that mismatch is what the attacker relies on.
Was Ethereum broken by the DAO hack?
No. Ethereum's co-founder said at the time that the flaw was in The DAO's contract, not in Ethereum itself. The network later made a change, called a hard fork, to move the drained funds into a contract where holders could reclaim them.
What is checks, effects, interactions?
It is an order of steps for writing contract functions. First check the conditions. Then make the changes to your own records. Only then call other programs or send money. The Solidity guide recommends this order as a way to guard against reentrancy.
Do I need to know coding to care about reentrancy?
Not really. If you put money into crypto projects, you can still ask whether the project has had an independent audit and how it was tested. You do not need to read the code to ask those questions or to read an audit summary.
Is a reentrancy guard enough on its own?
Usually it is one layer, not the whole answer. OWASP recommends both a guard and the records-first order, plus reviews of calls between functions and contracts, and tests that try to call back in.
Where next?
Ready for the detail? Read the practitioner guide: OWASP Smart Contract Reentrancy. It goes further into checks, effects, interactions in code, reentrancy guards, read-only and cross-contract reentrancy, and how auditors test for it.
Also useful:
- Smart Contract Security for Beginners
- Smart Contract Auditor for Beginners
- Crypto Wallets and Keys for Beginners
- Multisig Wallets for Beginners
Related NHI Mgmt Group resources: Crypto Scams for Beginners
Key terms
- Reentrancy
- A flaw where a caller gets back into a contract before its first request has finished.
- Smart contract
- Code stored on a blockchain that runs its rules automatically when someone uses it.
- Reentrancy guard
- A lock that stops a function being entered again before the first run has finished.
- Checks, effects, interactions
- An order of steps: check conditions, update your own records, then call other programs.
- Ethereum
- A public blockchain that runs smart contracts and uses a currency called ether (ETH).
- Hard fork
- A change to a blockchain's rules that every participant must adopt to stay on the same chain.
- Smart contract audit
- A structured review of contract code to find flaws before real money is put in.
Sources and further reading
- Security considerations: reentrancy and the Checks-Effects-Interactions pattern. Solidity documentation. https://docs.soliditylang.org/en/latest/security-considerations.html, accessed 28 Nov 2026.
- SC08:2026 Reentrancy Attacks. OWASP Smart Contract Top 10, OWASP Foundation. https://owasp.org/www-project-smart-contract-top-10/2026/en/src/SC08-reentrancy-attacks.html, accessed 28 Nov 2026.
- Critical update re: DAO vulnerability. Vitalik Buterin, Ethereum Foundation Blog, 17 June 2016. https://blog.ethereum.org/2016/06/17/critical-update-re-dao-vulnerability, accessed 28 Nov 2026.
- The history of Ethereum: DAO fork. ethereum.org. https://ethereum.org/en/ethereum-forks/, accessed 28 Nov 2026.