Skip to content
Menu
Finabase Learn

Glossary

Reentrancy attack

A smart contract exploit in which an attacker calls back into a contract before it updates its records, withdrawing the same balance again and again.

On this page
  1. The DAO, 2016
  2. Defenses
  3. Related terms

A reentrancy attack is a bug in a smart contract that lets an attacker withdraw the same money more than once. The flawed contract sends funds first and updates the balance afterwards. If the recipient is itself a contract, it can use the moment of payment to call the withdraw function again, before the first call has finished. Each repeat call still sees the old, full balance.

The DAO, 2016

The best-known case hit The DAO, an investment fund run as contracts on Ethereum. Its token sale in April and May 2016 raised about 12 million ether. On June 17, 2016 an attacker used a recursive-call flaw of this kind to divert about 3.6 million ether, a third of the total. Ethereum's community reversed it with a hard fork on July 20, 2016 and returned the ether to the token holders, a step the chain has not repeated.

Defenses

  • Update first, pay last. The contract cuts the balance to zero before sending anything.
  • A lock. A guard refuses any new call into the function while one is still running.
  • Audits. Reviewers look for this pattern, though an audit does not prove a contract is safe.

Reentrancy still appears in DeFi contracts today, often in subtler forms that cross several contracts.

Sources and further reading

  1. SEC — Report of Investigation Pursuant to Section 21(a): The DAO (Release No. 81207, July 25, 2017)

Written and fact-checked by Finabase Research. Last reviewed . Spotted an error? Tell us.

Educational content, not investment advice. Finabase Learn explains how markets and tools work. It does not recommend any security or strategy, and examples are for illustration only. Investing involves risk, including the loss of principal. Rules and figures are for the United States unless stated and can change — check the cited source before you act. Data and corrections policy.