The DAO 1.0 – The Bug And The Hack, The Refunds, Plus The Source Code And ABI

Originally posted Sep 15 2016. Updated Oct 29 2016 with The DAO hacker successfully converting ~ USD 100,000 of booty into bitcoins

The DAO (borrowed from slock.it)

The DAO (borrowed from slock.it)

The DAO, the first-of-a-kind decentralised autonomous venture capital fund on the Ethereum virtual currency blockchain started it’s 28 day crowdfunding phase on Apr 30 2016. It raised the equivalent of USD 150 million from over 20,000 separate accounts. The DAO consists of 1236 lines of source code running at account 0xbb9bc244d798123fde783fcc1c72d3bb8c189413. Click here to view the source code in the Online Solidity Editor.

The DAO Bug And The Hack

The DAO was hacked to the tune of USD 50 million (~ 30%) on Jun 17 2016 by exploiting a bug in the highlighted lines within the withdrawRewardFor(...) function below. Moving line 9 before line 7 would have prevented this attack (but it is easy to spot now after the event):

Here is the bug fix in The DAO’s github repository.

What the hacker did was to withdraw their ethers into an Ethereum smart contract that recursively called the splitDAO(..) function which calls the withdrawRewardFor(...), up to a depth of 29 recursive calls. So the transfers were executed 29 times without paidout[_account] being incremented with the amount already paid out. The attacking code also transferred the account’s The DAO tokens between different contracts to prevent these token amounts being zeroed out.

For further details of the hack see my Ethereum.StackExchange.com Q&As:


Accounts


History


The DAO Refunds

The Ethereum node client software was modified to hard-fork the Ethereum blockchain at block 1,920,000 on Jul 20 2016. Ethers (ETH) in The DAO and it’s child DAOs were swept up into the curator’s multisig contract. These ETHs are being refunded fairly to The DAO investors in full – see the base refund, the extraBalance refund and the split DAO refund.

See also One Month After Ethereum Fork, Millions in DAO Funds Unclaimed where yours truly from New Zealand is mentioned.

Poloniex unexpectedly listed the non-forked Ethereum blockchain (called Ethereum Classic with ETC coins) on Jul 24 2017. ETCs are currently trading at about 12% of the original ETH price (1 ETC = 1.430 USD or 1.894 AUD while 1 ETH = 12.000 USD or 15.895 AUD). The Goodies used the same hack as the Baddies to drain the remaining ETCs on the Ethereum Classic chain and are expecting to return 71% of ETCs to The DAO investors. 60% of the funds is already available for The DAO investors to withdraw, with the remaining available in a few weeks.

And the Baddies will have access to 3641694.241898506992612606 ETCs from Mon, 05 Sep 2016 21:56:22 UTC. The current value for this stash is around USD 5.5 million. But it may be difficult for the Baddies to convert these funds into cash or other untraceable currencies.


The DAO Refund Procedures

Update 22:51 Sep 5 2016 UTC – The Hacker Has Just Withdrawn Their Booty From The DAO On The ETC Chain.

Update Oct 29 2016 01:26:11 UTCThe DAO Hacker’s Booty Is On The Move, The Plot Thickens As DAO Attacker Trades Stolen Funds for Bitcoin and The DAO Hacker Cashes Out.


The Source Code

Table of contents


For easier reading, I have stripped out all but the first GPL licence text, separated the individual contracts and interfaces and removed unnecessary blank lines.

GPL v3 Copyright

Contract TokenInterface

Contract Token (is TokenInterface)

Contract ManagedAccountInterface

Contract ManagedAccount (is ManagedAccountInterface)

Contract TokenCreationInterface

Contract TokenCreation (is TokenCreationInterface, Token)

Contract DAOInterface

Contract DAO (is DAOInterface, Token, TokenCreation)

Note that the withdrawRewardFor(..) code below has a USD 50 million bug.

Contract DAO_Creator


The Application Binary Interface – Full Version

Following is the Application Binary Interface (ABI) for The DAO listed at account 0xbb9bc244d798123fde783fcc1c72d3bb8c189413 on etherscan.io.


The Application Binary Interface – Short Version

Following is the ABI for The DAO listed from the page The DAO – Voting.

This entry was posted in Blog and tagged , , , , . Bookmark the permalink.