How did the DAO get hacked? Can someone explain in simple terms?
The simple high level explanation would be like this;
When you (as a DAO token holder) split from DAO, it creates a new child DAO and pays you back (in a transaction) your share by sending it to the new splitted DAO, (your DAO).
The attacker created a loop (by recursively calling the
splitDAO function) caused the DAO paying several times instead of once.
This loop caused the DAO repeatedly (27996 times) transact the amount of
237.62451099999999 Ether to the new child DAO.
Ethcore blogpost does a good job at describing the history of the hack. Basically they knew about the vulnerability two days before the attack and fixed the function that they though was affected. Read more here slock.it blog.
From the guy who wrote about the vulnerability before the attack:
I wrote up this vulnerability last week: you can read more about it at my blog. In simple words, it's like the bank teller doesn't change your balance until she has given you all the money you requested. "Can I withdraw $500? Wait, before that, can I withdraw $500?"
And so on. The smart contracts as designed only check you have $500 at the beinning, once, and allow themselves to be interrupted.
The blog post he mentions can be found here.
A reasonable analogy I've heard is:
- You go to an ATM and withdraw the money.
- After the ATM gives you the money, you unplug the ATM before it updates your account.
- You plug the ATM back, withdraw money and repeat the process.
One of the things that can help mitigate this reentrant attack is for the ATM update to your account first, before giving you the money.