Module 16: Postmortems
The DAO (2016): When Code Was Law, and Then Wasn't
Chapter 3 of 12 · about 4 minutes
3.1 What it was
In 2016, a project called The DAO launched on Ethereum, which was barely a year old. It was designed as a decentralised venture fund: people sent ETH to a smart contract, received tokens, and could vote on which projects the fund would invest in. No company, no managers, just code.
It raised ETH worth roughly $150 million at the time, a substantial share of all ETH in existence, making it one of the largest crowdfunding efforts ever at that point.
People trusted it because the code was public, the idea was exciting, and the slogan of the moment was "code is law": whatever the smart contract allowed was, by definition, legitimate.
3.2 What happened
| Date | Event |
|---|---|
| April to May 2016 | The DAO raises a large amount of ETH |
| Before June 2016 | Researchers publicly raise concerns about potential vulnerabilities |
| June 2016 | An attacker exploits a flaw in the withdrawal function, repeatedly withdrawing funds before the contract updated its balance, a type of bug called reentrancy |
| June 2016 | About a third of The DAO's ETH is moved into a separate contract controlled by the attacker, with a waiting period before it could be withdrawn |
| July 2016 | After intense debate, the Ethereum community adopts a hard fork that moves the affected funds to a recovery contract, letting investors reclaim their ETH |
| July 2016 onwards | A minority who rejected the fork continued the original chain, now known as Ethereum Classic |
3.3 The reentrancy bug, simply
Imagine a cash machine that gives you money first and updates your balance afterwards. If you could press "withdraw" again in the split second before the balance updated, you'd get paid again from the same balance, repeatedly.
That's essentially what happened. The DAO's code sent ETH before updating the attacker's balance, and the attacker's contract called back into the withdrawal function again and again.
In numbers, a third of the roughly $150 million raised was about $50 million, drained into a separate contract the attacker controlled.
Chapter 3 · The DAO reentrancy bug
The DAO's withdraw function sent ether to the caller before updating the caller's recorded balance. A malicious contract used its receive function to call withdraw again before the first call finished, repeating the loop and draining funds while its balance still showed the original amount.
3.4 Warning signs
| Warning sign | Module |
|---|---|
| Brand new, unproven code holding a huge amount of value | Module 9, Chapter 13 |
| Public warnings from security researchers before the attack | Module 5, Chapter 2 |
| A young ecosystem with immature tools and few audits | Module 9, Chapter 13 |
| Enthusiasm and speed outrunning caution | Module 11, Chapter 2 |
3.5 Aftermath
The DAO hack shaped Ethereum and DeFi in lasting ways:
- A permanent split. Ethereum and Ethereum Classic still exist as separate chains (Module 1, Chapter 4).
- The "code is law" debate. The fork showed that communities can intervene in extreme cases, which some see as pragmatic and others as a betrayal of immutability (Module 3, Chapter 13).
- Security practices matured. Reentrancy became one of the first vulnerabilities that every smart contract developer learns to prevent, and audits became standard for serious projects.
- Regulatory attention. In 2017, the US SEC issued a report concluding that DAO tokens were securities, an early sign of how regulators might view token sales (Module 14, Chapter 7).
"So a single bug changed the whole ecosystem," said Node.
"And nearly every later smart contract hack is a variation on the same theme," said Hash. "New code, lots of money, not enough scrutiny."
3.6 Lessons
- New code holding large funds is risky, no matter how exciting the idea. Time without incident is one of the best safety signals (Module 9, Chapter 13).
- Read the security warnings. Researchers often flag risks before they're exploited.
- Size positions in new protocols to survive total loss (Module 9, Chapter 13).
- "Decentralised" doesn't mean "safe" (Module 1, Chapter 15).
- Don't count on a rescue. The DAO fork was exceptional; most hacked protocols never return funds.
3.7 Try it yourself
Find a DeFi protocol you're interested in. Look up how long its core contracts have held significant value, how many audits it has had, and whether it has a bug bounty. Then search for any public security concerns raised about it. Would you have invested in The DAO in 2016, knowing what you know now?
Key takeaways from this chapter
- The DAO was a 2016 smart contract investment fund on Ethereum that raised a large share of all ETH.
- A reentrancy bug let an attacker drain about a third of its funds.
- Ethereum hard-forked to return funds, creating the split with Ethereum Classic.
- Warning signs included new unproven code, large value, and public security concerns.
- The episode shaped audit practices, the "code is law" debate, and regulatory views of tokens.
- Treat new code holding large funds with caution and size positions to survive total loss.