In June 2016, the Ethereum ecosystem experienced one of its most dramatic and consequential events: the hack of The DAO. This event shook the community to its core, led to a controversial hard fork, and left lasting lessons about smart contract security that are still relevant today.
What Was The DAO?
The DAO (Decentralized Autonomous Organization) was a groundbreaking experiment in decentralized governance and venture capital. Launched in April 2016, it raised over $150 million worth of Ether in what was, at the time, the largest crowdfunding campaign in history.
The concept was revolutionary: a leaderless investment fund governed entirely by smart contracts and its token holders. Anyone holding DAO tokens could vote on proposals for investments, and profits would be distributed back to token holders.
The Vulnerability: Reentrancy Attack
The attack that drained The DAO exploited a classic smart contract vulnerability: reentrancy. The concept is surprisingly straightforward once you understand it.
The vulnerable code pattern looked something like this:
// VULNERABLE CODE - DO NOT USE
function withdraw(uint amount) public {
if (balances[msg.sender] >= amount) {
// DANGER: External call BEFORE updating state
msg.sender.call.value(amount)();
balances[msg.sender] -= amount; // Too late!
}
}
Here’s the attack sequence:
- Attacker creates a malicious contract with a fallback function
- Attacker calls
withdraw()with their balance - The DAO sends Ether to the attacker’s contract
- The attacker’s fallback function immediately calls
withdraw()again - Because the balance hasn’t been updated yet, the check passes again
- This loop repeats, draining the contract
The Scale of the Attack
The attacker exploited this vulnerability to drain approximately 3.6 million Ether (worth about $50 million at the time) into a “child DAO.” The attack was elegant in its simplicity — the attacker wasn’t breaking any rules, merely exploiting the contract’s logic against itself.
Importantly, the attacker’s funds were locked in a time-locked child DAO, giving the Ethereum community a window to respond.
The Controversial Response: Hard Fork
What happened next is still debated today. The Ethereum Foundation proposed a hard fork to effectively reverse the hack and return funds to DAO token holders. This was deeply controversial because it violated the “code is law” principle that many considered fundamental to blockchain’s value proposition.
The community was split:
- Pro-fork: The attack was a bug exploit, not a legitimate transaction. The smart contract community needed to show it could respond to catastrophic failures.
- Anti-fork: Reversing transactions on an “immutable” blockchain set a dangerous precedent. “Code is law” must mean something.
The hard fork passed, creating two chains: Ethereum (ETH) — the forked chain where the hack was reversed, and Ethereum Classic (ETC) — the original chain where the hack remained.
Lessons Learned
The DAO hack fundamentally changed how smart contracts are written and audited:
- Checks-Effects-Interactions pattern: Always update state before making external calls
- Reentrancy guards: Use mutex-style locks to prevent reentrant calls
- Security audits: Professional smart contract auditing became standard practice
- Formal verification: Mathematical proofs of contract correctness gained importance
// SECURE VERSION
function withdraw(uint amount) public {
require(balances[msg.sender] >= amount);
// Update state FIRST
balances[msg.sender] -= amount;
// Then make external call
msg.sender.transfer(amount);
}
Conclusion
The DAO hack was a painful but ultimately valuable lesson for the entire blockchain ecosystem. It demonstrated that smart contracts, despite running on an immutable blockchain, are only as secure as the code they contain.
More importantly, it showed that the blockchain community could respond to crises, even if the response itself was controversial. The debate about immutability versus pragmatism continues to this day and is fundamental to understanding how blockchain governance works.
The attacker(s) technically followed all the rules. In “code is law,” they won. The community disagreed and changed the rules. Both of these things are true, and both say something important about what blockchain technology is and isn’t.