1 00:00:00,000 --> 00:00:01,360 All right, everybody. 2 00:00:02,360 --> 00:00:03,400 Welcome. 3 00:00:03,560 --> 00:00:06,400 Thank you for attending my talk, Hacking Cryptocurrencies. 4 00:00:07,040 --> 00:00:08,760 My name is Mark Nesbitt. 5 00:00:08,760 --> 00:00:11,400 I'm an application security engineer at Coinbase. 6 00:00:12,380 --> 00:00:22,020 In the blockchain village at DEF CON, you all probably know Coinbase, but for those who may be unfamiliar, Coinbase is a digital currency wallet and platform where merchants and consumers can transact with cryptocurrency. 7 00:00:22,460 --> 00:00:30,560 Some of my recent priorities at my job have been security support for systems that integrate with cryptocurrency networks, for instance, our hot wallets. 8 00:00:31,040 --> 00:00:35,180 And second has been security assessments and mitigations for supported digital assets. 9 00:00:35,180 --> 00:00:41,860 As you may know, Coinbase is adding a large number of assets to the platform, and we review each and every one of them for its security qualities. 10 00:00:45,120 --> 00:00:47,320 I'm going to have two main sections to this talk. 11 00:00:47,320 --> 00:00:51,180 First, I'm going to talk about what I mean by hack when I say hacking cryptocurrencies. 12 00:00:51,880 --> 00:00:55,320 Second section, I'm going to talk about 51% double spending attacks. 13 00:00:55,320 --> 00:00:57,960 I'm going to walk through some real world examples of this. 14 00:00:57,960 --> 00:01:03,420 And then I'm going to talk about some observed patterns and characteristics of the attacks and the attackers that we've been able to uncover. 15 00:01:04,660 --> 00:01:06,920 First, what do we mean by hack? 16 00:01:07,980 --> 00:01:11,320 With every new technology, a new exploit vector is born. 17 00:01:11,360 --> 00:01:20,060 New processor developments, like speculative execution or out of order execution, were exciting boosts to processor speed and also enabled the famous specter and meltdown vulnerabilities. 18 00:01:20,460 --> 00:01:21,580 Blockchains are no different. 19 00:01:21,580 --> 00:01:24,840 They represent a new technology, which means there are new ways to hack. 20 00:01:24,840 --> 00:01:26,480 I'll explain one of them here. 21 00:01:27,160 --> 00:01:30,400 Most everyone here is likely familiar with the CIA framework for security. 22 00:01:30,400 --> 00:01:33,600 C for confidentiality, I for integrity, and A for availability. 23 00:01:34,020 --> 00:01:39,140 Examining a system for these three properties can give a great start into understanding the security and threats against the system. 24 00:01:39,840 --> 00:01:42,800 I'll describe how 51% attacks work in a bit more detail. 25 00:01:42,800 --> 00:01:49,480 But for the time being, it's important to realize that a cryptocurrency is a network of nodes that communicate to one another according to a protocol. 26 00:01:49,580 --> 00:01:54,020 The nodes on the network store a copy of the blockchain, which is a public shared database. 27 00:01:54,100 --> 00:01:58,120 And the network protocol allows nodes to communicate state information about the blockchain. 28 00:01:59,620 --> 00:02:04,100 Nearly every blockchain has an authorization model based on public key cryptography. 29 00:02:04,100 --> 00:02:09,060 The state of data in the blockchain can usually only be updated when the proper digital signature is provided. 30 00:02:09,140 --> 00:02:12,160 An example of this would be sending bitcoins from one person to another. 31 00:02:12,160 --> 00:02:16,460 The sender must authorize this state change by signing the send transaction. 32 00:02:16,460 --> 00:02:21,400 A wallet is an example of software that performs this action, meaning that it's built on top of the blockchain. 33 00:02:21,640 --> 00:02:24,700 Wallets hold private keys and can submit transactions to the blockchain. 34 00:02:24,980 --> 00:02:32,720 As you could realize, because the blockchain is a shared public database, anyone can choose to build a wallet application on top of a blockchain, so there are a wide variety of wallets. 35 00:02:32,740 --> 00:02:35,300 They have their own CIA to examine. 36 00:02:35,580 --> 00:02:39,540 Many of the hacks you hear about in the media are a failure of confidentiality in the parts of wallets. 37 00:02:39,540 --> 00:02:41,940 Peter mentioned that just a few minutes ago in his talk. 38 00:02:42,580 --> 00:02:49,340 If the private keys are leaked, anyone can authorize transactions for actions controlled by those keys. 39 00:02:51,600 --> 00:02:54,400 Another interesting wallet failure mode is integrity failure. 40 00:02:54,400 --> 00:02:55,620 Peter also mentioned this. 41 00:02:55,620 --> 00:03:02,320 If an attacker can manipulate the recipient of a transaction prior to signing, there's no need for the attacker to have access to the private keys. 42 00:03:02,320 --> 00:03:05,200 All of this is pretty standard application security work. 43 00:03:05,200 --> 00:03:07,940 There's a lot of history in how to secure these types of systems. 44 00:03:07,940 --> 00:03:12,920 A large component of my day-to-day work is doing that, ensuring confidentiality and integrity in these systems. 45 00:03:14,000 --> 00:03:18,020 For completeness, I've given two examples of availability failure that might happen. 46 00:03:18,020 --> 00:03:21,020 These aren't really hacks because the attackers don't really get the funds. 47 00:03:21,580 --> 00:03:23,340 But this talk is not about wallets. 48 00:03:23,340 --> 00:03:26,760 I'm talking about hacking cryptocurrency itself, a new vector. 49 00:03:26,960 --> 00:03:29,040 Let's see where the CIA framework can get us there. 50 00:03:30,660 --> 00:03:33,080 I define the blockchain as a shared database. 51 00:03:33,080 --> 00:03:36,900 Thus, it's entirely transparent, and there really isn't very much confidentiality. 52 00:03:37,480 --> 00:03:45,620 Jumping down to availability, this is also not going to be a focus because it's not a huge concern for anyone except for the protocol designers. 53 00:03:45,960 --> 00:03:46,940 These concerns matter. 54 00:03:46,940 --> 00:03:51,060 Concerns about the availability of blockchains have driven much of what's known as the scaling debate. 55 00:03:51,600 --> 00:04:01,380 If protocol design makes the resources required to run and participate in the network too expensive, it may impact the availability of the information, which could have many negative impacts on the network. 56 00:04:03,380 --> 00:04:06,780 Violating the integrity of a blockchain is what I want to talk about. 57 00:04:06,880 --> 00:04:08,700 It's a way to hack cryptocurrency. 58 00:04:08,900 --> 00:04:13,360 The integrity has recently become a bigger focus across the industry. 59 00:04:16,320 --> 00:04:20,060 As I mentioned before, I work for Coinbase, a major cryptocurrency exchange. 60 00:04:20,520 --> 00:04:27,040 Exchanges make an ideal target for all kinds of attacks, but especially 51% attacks, which I'll dive into in the second part. 61 00:04:28,320 --> 00:04:31,600 First off, exchanges hold a lot of cryptocurrency on behalf of their customers. 62 00:04:31,600 --> 00:04:34,280 That's an obvious enough reason for them to be good targets. 63 00:04:34,680 --> 00:04:36,440 There are other characteristics, though. 64 00:04:36,440 --> 00:04:38,260 For instance, liquidity and volume. 65 00:04:38,260 --> 00:04:42,800 Being able to trade one cryptocurrency into a different one can be very advantageous to an attacker. 66 00:04:43,380 --> 00:04:44,180 Speed. 67 00:04:44,480 --> 00:04:50,060 Exchanges often credit funds to attackers on a relatively short time frame and allow for nearly instant sends. 68 00:04:50,060 --> 00:04:52,380 An attack could therefore happen very quickly. 69 00:04:53,820 --> 00:04:55,140 Remote interaction. 70 00:04:55,140 --> 00:04:59,780 An attacker can execute many of these attacks from across the ocean, perhaps from North Korea. 71 00:05:00,520 --> 00:05:03,100 And in some cases, anonymity. 72 00:05:03,140 --> 00:05:04,800 I want to take a second to talk about this. 73 00:05:04,800 --> 00:05:12,040 Many popular media descriptions of cryptocurrency seem to describe it with some magical anonymity qualities, which it doesn't have. 74 00:05:12,100 --> 00:05:16,100 This is especially true if you have an authenticated session with an exchange such as Coinbase. 75 00:05:16,400 --> 00:05:20,080 Coinbase strives to be the most trusted exchange in the entire cryptocurrency industry. 76 00:05:20,140 --> 00:05:21,960 And as part of that, we're heavily regulated. 77 00:05:21,960 --> 00:05:27,920 And a large part of that regulation involves the lengths we go to ensure every customer on our platform has gone through KYC, AML. 78 00:05:28,100 --> 00:05:30,600 KYC, know your customer, so we know their identities. 79 00:05:30,680 --> 00:05:32,980 And that's important for AML, anti-money laundering. 80 00:05:33,120 --> 00:05:38,780 Any exchange that doesn't have these strict requirements would obviously be more attractive to potential attackers. 81 00:05:39,640 --> 00:05:52,620 So if you can find some sort of vulnerability, whether that's subverting a protocol or a more traditional wallet-style vulnerability, as I described earlier, this makes an exchange a great target. 82 00:05:55,630 --> 00:05:58,610 So 51% double spend attacks. 83 00:05:59,230 --> 00:06:04,230 As I mentioned before, a blockchain is a shared database stored by all nodes on the network and accessible to anyone. 84 00:06:05,050 --> 00:06:08,070 For this database to be useful, there must be a way to update it. 85 00:06:08,350 --> 00:06:12,590 Blockchains are append-only databases and are updated in batches of transactions. 86 00:06:12,710 --> 00:06:16,370 Each batch of transactions that's added to the blockchain is typically called a block. 87 00:06:17,310 --> 00:06:23,370 So you can visualize the blockchain like this with the expectation that a block n plus one would shortly be added. 88 00:06:24,050 --> 00:06:25,450 But that raises a question. 89 00:06:25,450 --> 00:06:27,310 Who defines block n plus one? 90 00:06:27,330 --> 00:06:33,990 The database is shared and distributed, so there must be some way of coming to consensus among the network participants about what constitutes this block. 91 00:06:34,030 --> 00:06:36,790 The answer to this question is it depends on the cryptocurrency. 92 00:06:36,910 --> 00:06:43,830 This is one of the major defining characteristics of cryptocurrencies, and a lot of new cryptocurrencies have innovative methods for adding to the blockchain. 93 00:06:44,630 --> 00:06:51,930 For instance, Ripple and Stellar have a concept of validator nodes that use a voting consensus protocol to determine which transactions are in this block. 94 00:06:52,630 --> 00:06:59,350 EOS goes through regular elections where these nodes are called block producers and they take turns defining the block. 95 00:06:59,830 --> 00:07:04,090 Tezos and Cosmos, the node chosen is based on its stake. 96 00:07:04,090 --> 00:07:07,710 It's a proof-of-stake network and stake is the proportion of network funds owned. 97 00:07:08,470 --> 00:07:10,710 Lastly, Bitcoin and Ethereum. 98 00:07:11,050 --> 00:07:14,890 The node that first successfully solves a cryptographic puzzle defines the block. 99 00:07:15,210 --> 00:07:16,830 This is known as proof of work. 100 00:07:17,330 --> 00:07:23,590 It's known as proof of work because the solution to the cryptographic puzzle has to be brute-forced, which takes considerable computational effort. 101 00:07:23,590 --> 00:07:24,730 This is called mining. 102 00:07:25,050 --> 00:07:28,370 Mining a block is when a node discovers the solution to the proof-of-work puzzle. 103 00:07:28,890 --> 00:07:31,750 Here's a key fact about proof-of-work networks. 104 00:07:32,010 --> 00:07:37,590 Anyone can bring their computation to the table and if they produce a valid block, they have extended the blockchain. 105 00:07:37,930 --> 00:07:44,870 Since this is a distributed and permissionless way of extending the blockchain, it's possible that the network will encounter multiple versions of the blockchain. 106 00:07:45,110 --> 00:07:52,610 To resolve these versions and reach consensus on a single version, the network deems the version with the most work to be the canonical blockchain. 107 00:07:52,610 --> 00:07:54,150 I'll explain what I mean by that. 108 00:07:54,350 --> 00:07:58,170 This diagram shows the blockchain tilted 90 degrees with the blocks separated. 109 00:07:58,170 --> 00:08:01,030 Block n plus one will be added on top of the other blocks. 110 00:08:01,090 --> 00:08:04,210 As before, each block contains some number of transactions. 111 00:08:04,890 --> 00:08:10,770 Suppose a node with its computational power solves the cryptographic puzzle, mines a block. 112 00:08:10,830 --> 00:08:18,370 It broadcasts the block that solves this puzzle to the network and all transactions in the block are added to the canonical history of transactions that is added to the blockchain. 113 00:08:19,630 --> 00:08:22,270 But suppose the second block is found simultaneously. 114 00:08:22,690 --> 00:08:26,090 How does the network decide which block contains the transactions that are to be added? 115 00:08:26,870 --> 00:08:32,410 The rule is that the nodes on the network define the series of blocks with the most work as the canonical history. 116 00:08:32,610 --> 00:08:40,370 So if either of the two blocks gets another block extending on top of it, there will be more accumulated work on that branch, which makes it the canonical blockchain. 117 00:08:41,890 --> 00:08:45,550 This means that there's never a case where a block is truly finalized on the chain. 118 00:08:45,630 --> 00:08:53,010 If enough work decides to extend from a different block, once that branch has outworked the rest of chain, it will be the canonical history. 119 00:08:53,470 --> 00:09:01,550 The situation on the slide is called a reorg, short for reorganization, and the grayed out blocks are known as orphan blocks, and they are not part of the blockchain. 120 00:09:03,130 --> 00:09:04,770 Let me repeat a key fact. 121 00:09:04,770 --> 00:09:14,350 Any actor that can outwork the rest of the network is the sole arbiter of which, among all possible valid transactions, are the ones that are added to the canonical history. 122 00:09:14,910 --> 00:09:25,630 So if there's any kind of network instability where blocks were not always immediately shared with the network after they were found, or if some actor was deliberately holding back blocks that had been discovered, we could see something like what's shown on this slide, 123 00:09:25,630 --> 00:09:27,870 where the blocks on the left are hidden from the network. 124 00:09:27,870 --> 00:09:36,750 But if they were shared and made public, the network would switch over to these blocks and define them as the canonical chain, orphaning all the blocks that were previously the most recent additions to the chain. 125 00:09:37,870 --> 00:09:51,190 Because of this potential for instability of the most recent blocks, anyone receiving a transaction should wait for several blocks to be found after the block that contained their transaction to lower the chance that the block containing their transaction will be orphaned. 126 00:09:51,430 --> 00:09:55,650 An analogy that I found interesting is that the most recent blocks are like recently fallen leaves in the fall. 127 00:09:55,650 --> 00:09:57,510 They can blow around and change and shift. 128 00:09:57,510 --> 00:10:04,730 After a while they might get waterlogged and not move very much, and after even longer they'll decompose into mud, clay, and eventually rock. 129 00:10:04,730 --> 00:10:11,670 You can adjust your risk by selecting the number of blocks that you wait until you consider a transaction finalized. 130 00:10:11,690 --> 00:10:17,310 This is known as the confirmation requirement, and each recipient of a transaction decides on their own level. 131 00:10:19,540 --> 00:10:26,020 So imagine we had the following situation where Coinbase supports a fictional coin, McCoin, abbreviated MUH. 132 00:10:26,140 --> 00:10:30,160 Suppose the confirmation requirement for MUH is three blocks. 133 00:10:30,400 --> 00:10:34,580 Coinbase also supports BTC, Bitcoin, and MUH trading. 134 00:10:34,920 --> 00:10:37,660 Any customer of Coinbase could have the following intention. 135 00:10:37,660 --> 00:10:41,720 Create a transaction T that sends coins from the customer's wallet to Coinbase. 136 00:10:41,720 --> 00:10:51,080 Wait for three blocks, after which Coinbase will consider the transaction finalized, and Coinbase will credit these funds to the customer's Coinbase account. 137 00:10:51,080 --> 00:10:57,540 Then the customer may want to sell the MUH for BTC and then send the BTC wherever they like, off-site, off the platform. 138 00:10:57,540 --> 00:11:00,820 This is a completely normal pattern of behavior for a customer to take. 139 00:11:02,420 --> 00:11:06,640 Let's imagine instead though that the customer is actually an attacker. 140 00:11:06,680 --> 00:11:10,600 An attacker with a special ability to outwork the rest of the network. 141 00:11:11,100 --> 00:11:15,780 The attacker creates transaction T, sending some amount of MUH onto Coinbase. 142 00:11:15,780 --> 00:11:19,160 Suppose T is quickly included in a block by some miner on the network. 143 00:11:21,360 --> 00:11:24,980 Simultaneously, the attacker will create a second transaction, T'. 144 00:11:24,980 --> 00:11:30,200 Notice that T' sends the same funds that were sent in T, addressed at A1. 145 00:11:30,800 --> 00:11:34,240 However, T' sends those funds to address A2. 146 00:11:34,660 --> 00:11:37,420 T and T' could never exist in the same blockchain together. 147 00:11:37,420 --> 00:11:42,840 As soon as one is included, the other would be an invalid transaction because the funds were already spent. 148 00:11:43,500 --> 00:11:48,860 The attacker begins to mine in secret and includes T' in the secret block, but not T. 149 00:11:49,220 --> 00:11:54,440 The space on the right with the gray background is local to the attacker and the network cannot see this block. 150 00:11:54,920 --> 00:12:01,920 Remember that we've assumed the attacker can outwork the rest of the network, meaning the attacker can produce blocks faster than the rest of the entire network. 151 00:12:03,640 --> 00:12:10,000 So in order to do anything with the MUH on Coinbase, it first needs to have three confirmations because that's what it takes to be credited. 152 00:12:10,940 --> 00:12:15,060 The attacker does not sit idly by and continues to secretly produce blocks. 153 00:12:15,620 --> 00:12:21,740 The network also produces blocks, but unknown to anyone, it's not keeping pace with the secret blocks produced by the attacker. 154 00:12:23,000 --> 00:12:27,420 Finally, the network produces the third block, three confirmations on the transaction. 155 00:12:27,420 --> 00:12:32,860 The attacker is now credited with the MUH and can sell it for BTC, which could then be sent off the Coinbase platform. 156 00:12:33,440 --> 00:12:35,720 So the BTC could be withdrawn. 157 00:12:36,000 --> 00:12:38,060 It's now in the attacker's control. 158 00:12:38,080 --> 00:12:41,800 Remember, nothing seen publicly thus far is anything out of the ordinary. 159 00:12:42,240 --> 00:12:44,660 But now the attacker can execute the attack. 160 00:12:44,760 --> 00:12:47,380 The attacker can reveal the blocks to the network. 161 00:12:47,420 --> 00:12:50,660 These blocks have more accumulated work than the existing top three blocks. 162 00:12:50,660 --> 00:12:53,920 So according to the network rules, a reorg will occur. 163 00:12:53,920 --> 00:12:56,740 The attacker's blocks now representing the canonical chain. 164 00:12:57,080 --> 00:13:01,340 The top three blocks that we've previously seen publicly now become orphan blocks. 165 00:13:01,340 --> 00:13:06,580 They're no longer part of the blockchain and the transactions defined in them are now no longer part of the canonical history. 166 00:13:07,220 --> 00:13:12,560 And notice the T was in those blocks, meaning that there's no longer a transaction to Coinbase in the blockchain anymore. 167 00:13:12,640 --> 00:13:15,260 But the BTC has already been withdrawn. 168 00:13:15,260 --> 00:13:19,300 There was a withdrawal , there was no deposit, aka a theft. 169 00:13:19,500 --> 00:13:24,320 The ability to do this is directly related to how difficult it is for an attacker to overpower the network. 170 00:13:24,320 --> 00:13:33,520 The more work being put into solving the proof of work puzzles on the network, the more difficult it will be for any one entity to marshal the resources and overwhelm the network. 171 00:13:34,420 --> 00:13:39,460 Note that the danger of this attack comes when you accept a deposit directly from the attacking entity. 172 00:13:39,500 --> 00:13:43,800 In this example, BTC was provided in exchange for MUH. 173 00:13:43,800 --> 00:13:49,780 If the attacker can't get something irrevocable in exchange for this vulnerable coin, the attack is invaluable. 174 00:13:49,920 --> 00:13:53,820 This is one of the reasons that an exchange is a great target for this attack, liquidity. 175 00:13:56,400 --> 00:14:01,120 The thing about 51% attacks is they're pretty obvious if you know what to look for. 176 00:14:01,760 --> 00:14:06,160 Each block in the blockchain is identified by its hash, providing a unique fingerprint. 177 00:14:07,260 --> 00:14:12,300 If the hash of block at height n changes from what it was before, that block was replaced with a new block. 178 00:14:12,300 --> 00:14:13,960 There must have been some kind of reorg. 179 00:14:15,400 --> 00:14:19,400 Small reorgs, shallow depth reorgs, happen on a regular basis. 180 00:14:19,400 --> 00:14:23,760 This is primarily driven by the fact that many nodes across the world are attempting to find blocks. 181 00:14:23,760 --> 00:14:31,400 There is some amount of latency in the network, so there will be race conditions where multiple blocks are found simultaneously and eventually only one will be in the blockchain. 182 00:14:32,260 --> 00:14:40,880 However, deeper reorgs do allow for attacks if they exceed the confirmation limit of the service. 183 00:14:43,540 --> 00:14:47,980 You can inspect a reorg to look for the presence of T and T prime. 184 00:14:48,380 --> 00:14:52,080 Two transactions are double spends if they send the same money but to different places. 185 00:14:52,080 --> 00:14:56,180 They can't exist in the chain together, but they might exist in competing branches of the chain. 186 00:14:56,340 --> 00:14:59,760 This is the smoking gun that a reorg is malicious. 187 00:14:59,760 --> 00:15:03,920 Money that was sent to one place is effectively clawed back when the new blocks are revealed. 188 00:15:05,840 --> 00:15:09,320 From the attacker's point of view, the attack has two components. 189 00:15:09,880 --> 00:15:14,020 One is the ability to form the secret chain, which requires majority hash power. 190 00:15:14,740 --> 00:15:18,200 Two, the ability to create transactions T and T prime. 191 00:15:18,300 --> 00:15:24,940 You're going to need some amount of the currency itself to do this, and the more coins you have, the bigger the impact of T and T prime. 192 00:15:26,540 --> 00:15:29,100 An attacker is also going to need to select a victim. 193 00:15:29,140 --> 00:15:36,720 Obviously, the victim must accept the currency, but the victim has to provide something of value that they cannot take back once they realize they've been attacked. 194 00:15:36,820 --> 00:15:38,920 So an attacker couldn't sell the coin for U.S. 195 00:15:38,920 --> 00:15:40,140 dollars and transfer the U.S. 196 00:15:40,140 --> 00:15:41,940 dollars to a bank account. 197 00:15:41,940 --> 00:15:46,420 Not only would that likely expose the attacker's identity, but the bank transfer can usually be reverted. 198 00:15:47,020 --> 00:15:51,460 Cryptocurrencies that aren't vulnerable to 51 percent attacks, however, cannot be reverted. 199 00:15:51,680 --> 00:15:57,020 This is another reason why cryptocurrencies exchanges make such good targets for 51 percent attacks. 200 00:15:57,020 --> 00:15:59,000 You can get cryptocurrency from them. 201 00:15:59,760 --> 00:16:09,960 Also notice that this attack can be repeated indefinitely until the victim takes defensive action, either by raising the confirmations required on their service or simply shutting down their interaction with this currency. 202 00:16:12,380 --> 00:16:17,500 We're going to walk through some real world examples of 51 percent double spending attacks. 203 00:16:18,220 --> 00:16:24,240 The one we'll go into most detail is the 51 percent attack on Ethereum Classic. 204 00:16:24,240 --> 00:16:34,580 In early January was when this happened, and because it's an asset that supports, we had monitoring systems in place which alerted in real time to the attack, allowing us to pause interaction with the blockchain. 205 00:16:34,960 --> 00:16:37,180 I'll talk about how this attack unfolded. 206 00:16:37,660 --> 00:16:42,340 The ETC network is minding its own business, mining blocks as usual, adding transactions to the blockchain. 207 00:16:44,360 --> 00:16:56,760 Then all of a sudden, seven new blocks show up out of nowhere, and these seven blocks don't extend from the most recent block, but dig down five blocks back, and it happens again. 208 00:16:56,760 --> 00:16:59,640 Six new blocks are fitting five previously discovered blocks. 209 00:17:00,440 --> 00:17:07,160 I called both of these events practice attacks, and the reason for that is because they were just reorgs. 210 00:17:07,160 --> 00:17:15,560 There was never a pair of transactions, T and T prime, where the same money was spent in one place in the first branch to a different place in the second branch. 211 00:17:16,480 --> 00:17:22,680 We hadn't observed reorgs of this depth ever on Ethereum Classic, and so it would have been premature to call these attacks. 212 00:17:22,820 --> 00:17:28,240 But once we were seeing these, we were alerted that something unusual was going on. 213 00:17:28,640 --> 00:17:32,540 And three hours later, there was a very deep reorg. 214 00:17:32,540 --> 00:17:37,000 74 new blocks showed up all at once, orphaning 57 blocks. 215 00:17:37,840 --> 00:17:46,200 And in this reorg, there was a T and T prime, where the same money was spent first to one place and then to another. 216 00:17:46,620 --> 00:17:48,040 This was on a Saturday night. 217 00:17:48,040 --> 00:17:53,560 Our on-call engineers responded, validated the alert, and turned off ETC send and receive functionality. 218 00:17:55,720 --> 00:18:01,880 Ethereum Classic isn't the only successful 51% attack. 219 00:18:01,880 --> 00:18:04,980 It's the one we're most familiar with because it's the one we were closest to. 220 00:18:05,420 --> 00:18:08,360 But I'm going to talk about two others that we've looked into closely. 221 00:18:08,360 --> 00:18:11,180 BTG is Bitcoin Gold, and VTC is Vertcoin. 222 00:18:11,180 --> 00:18:12,780 But those aren't the only other two. 223 00:18:12,780 --> 00:18:14,300 There have been others as well. 224 00:18:17,200 --> 00:18:21,900 Some of the observed patterns we see from looking into these three different attacks. 225 00:18:22,480 --> 00:18:24,720 It's important to realize blockchains are public. 226 00:18:25,440 --> 00:18:28,320 This means that a 51% attack is a pretty noisy attack. 227 00:18:28,320 --> 00:18:30,980 It leaves all kinds of good data for understanding the attackers. 228 00:18:31,140 --> 00:18:36,680 I'm going to walk through just a few of the things that we've observed, but they really only scratch the surface of what you can learn about an attacker. 229 00:18:36,680 --> 00:18:46,180 These attacks leave such a trail of damage, you could say, behind them that I don't think it would be very long before we're very good at learning quite a bit about attackers of this sort. 230 00:18:48,080 --> 00:18:57,440 This chart shows all 17 of the reorgs that we were able to find in our research into the Bitcoin Gold attack, and how much Bitcoin Gold was taken in each one of them. 231 00:18:57,680 --> 00:19:01,780 Notice the first two didn't take anything. 232 00:19:02,960 --> 00:19:05,100 This is Vertcoin, VTC. 233 00:19:05,100 --> 00:19:07,100 The first five took nothing. 234 00:19:08,240 --> 00:19:12,300 And notice the first two in Ethereum Classic also took nothing. 235 00:19:12,740 --> 00:19:15,960 Remember what I said, the 51% attack has two parts. 236 00:19:16,040 --> 00:19:21,140 First, being able to build the secret chain, and then properly creating transactions TNT Prime. 237 00:19:21,260 --> 00:19:22,620 So what did the attackers do? 238 00:19:22,620 --> 00:19:28,820 They broke the problem down into those two steps, made sure they could build an attack chain before they worried about building TNT Prime. 239 00:19:28,820 --> 00:19:31,120 Even criminals need integration tests. 240 00:19:33,120 --> 00:19:34,900 Criminals are also not perfect. 241 00:19:34,940 --> 00:19:37,400 These are the same three charts as before, all in one slide. 242 00:19:37,880 --> 00:19:41,540 You may have noticed that there were gaps when I first showed these to you. 243 00:19:41,820 --> 00:19:43,680 They're a little harder to explain, I think. 244 00:19:43,680 --> 00:19:52,320 But as far as I can tell, the attackers did a bunch of work in these cases to reorg the chain, but they didn't put in a TNT Prime, so they didn't cash in on any double spending. 245 00:19:52,680 --> 00:19:55,580 For the first few attacks, it makes sense to assume that they're practicing. 246 00:19:56,220 --> 00:20:00,600 But once they've proven they can do that, these just look like mistakes to me. 247 00:20:03,650 --> 00:20:07,270 There's also an invest-exploit decision that an attacker has to make. 248 00:20:07,530 --> 00:20:10,750 Imagine yourself in the attacker's shoes, and you kind of have an interesting dilemma. 249 00:20:10,750 --> 00:20:22,030 Once you have the hash power to successfully attack the network, any additional resources you have should be directed towards owning the currency itself to amplify the impact of TNT Prime. 250 00:20:22,390 --> 00:20:26,870 In other words, the cost of the attack and the payoff of the attack are not functions of one another. 251 00:20:27,250 --> 00:20:32,150 So as an attack progresses, you're accumulating resources if you're being successful. 252 00:20:32,150 --> 00:20:34,690 Should you reinvest these, or should you take them off the table? 253 00:20:34,910 --> 00:20:36,910 You know how I said blockchains are very transparent. 254 00:20:36,910 --> 00:20:39,890 We can observe the decisions they made clear as day. 255 00:20:41,590 --> 00:20:48,650 In the Bitcoin Gold attack, and in the vast majority of the Vertcoin attack, attackers are mostly in exploit mode. 256 00:20:48,650 --> 00:20:54,410 They have X amount of coins, and every time they attack the network, they perform a double spend, they get X payoff. 257 00:20:55,490 --> 00:21:03,110 But in the Ethereum Classic attack, and oddly in these first three Vertcoin attacks, the attackers seem to be also in invest mode. 258 00:21:03,130 --> 00:21:13,330 This makes me think that the Ethereum Classic attackers may have been planning to continue attacking, because I would expect an optimal attack profile to include a period of invest, followed by a flat period of exploit. 259 00:21:13,870 --> 00:21:17,170 There's also something really interesting about the Ethereum Classic data. 260 00:21:17,530 --> 00:21:19,310 Notice how it steps up in pairs. 261 00:21:19,550 --> 00:21:23,410 The first double spend was for a tiny amount, also probably a test. 262 00:21:24,310 --> 00:21:29,650 You can see at number four and five, they're roughly the same size. 263 00:21:30,110 --> 00:21:45,550 But then the size roughly doubled for six and seven, almost doubled again for eight and nine, stepped up significantly for 10 and 12, with 11 looking like it may have been another mistake, and then doubled again for 13 and 15, with 14 being another possible mistake. 264 00:21:45,790 --> 00:21:48,890 It seems to me that the attacker was balancing investing and exploiting. 265 00:21:48,930 --> 00:21:53,050 Bigger and bigger payoffs every time, but you never know when the party is going to stop. 266 00:21:53,270 --> 00:21:55,530 And so you want to take money off the table while you do it. 267 00:21:55,570 --> 00:21:57,070 That's what this looks like to me. 268 00:21:59,580 --> 00:22:02,140 This is also really profitable for the attackers. 269 00:22:02,740 --> 00:22:09,680 You can see our estimates on how much the double spends were worth, and our estimates on how much the mining cost would have been to perform these attacks. 270 00:22:09,680 --> 00:22:11,100 You can see the profit margins. 271 00:22:11,100 --> 00:22:12,140 It's absurd. 272 00:22:12,160 --> 00:22:14,880 Our mining cost estimates were also fairly conservative. 273 00:22:15,780 --> 00:22:19,640 We're also not even factoring the money made from the mining reward. 274 00:22:19,640 --> 00:22:22,480 The attacker mined valid blocks. 275 00:22:22,520 --> 00:22:25,700 Those blocks come with a mining reward, just like regular miners would have gotten. 276 00:22:25,700 --> 00:22:27,200 I'm not even factoring that in. 277 00:22:27,200 --> 00:22:30,640 They're approximately on the same order of magnitude as the mining cost, however. 278 00:22:34,020 --> 00:22:39,720 But the mining reward and leftover coins from the attack do typically get sold, so attackers are cashing in on this. 279 00:22:39,900 --> 00:22:50,220 In the case of Bitcoin Gold, it looked like about 75% of the mining rewards were moved shortly after the attack, probably to an exchange, probably to liquidate them, probably so that they could have coins that were unaffiliated with the attack. 280 00:22:50,820 --> 00:22:55,100 In Vertcoin and Ethereum Classic, all mining rewards were moved very shortly after the attack. 281 00:22:58,180 --> 00:23:02,900 Analyzing the time of day that the attacks happen is another route to understand the attackers. 282 00:23:02,900 --> 00:23:05,420 I've mapped the times of the attacks on this slide. 283 00:23:06,300 --> 00:23:09,920 It's hard to draw meaningful conclusions from Bitcoin Gold and Vertcoin. 284 00:23:09,920 --> 00:23:16,640 There does seem to be some clustering, but it's not too dramatic and they do have pretty much 24-hour coverage during the attack. 285 00:23:17,040 --> 00:23:21,440 Ethereum Classic, however, obviously has a time of day pattern in the attack. 286 00:23:21,520 --> 00:23:26,880 And that one outlier that you see was actually the very first practice attack, so it's a different case anyway. 287 00:23:27,260 --> 00:23:33,000 If such a major pattern does emerge, I would consider there to be two major hypotheses about what could be driving it. 288 00:23:33,000 --> 00:23:39,240 The attacker's preferred waking hours or the time zone the attacker considers most damaging to the victim, probably at night. 289 00:23:39,480 --> 00:23:48,440 Also note that the Ethereum Classic attacks and most of the Vertcoin attacks happened over weekends, again, probably because that is when it is most difficult for an exchange to respond. 290 00:23:49,460 --> 00:23:59,040 When doing timing analysis, note that these attacks can sometimes take hours for the attacker to build the chain, meaning the attacker doesn't have the full luxury of choosing their timing and may be forced to work around the clock. 291 00:23:59,040 --> 00:24:05,640 As an example, the longest Bitcoin Gold attack chain was 27 blocks, which probably took them over four hours to mine. 292 00:24:05,700 --> 00:24:11,420 The longest Vertcoin attack chain was 310 blocks, which probably took them over 12 hours to mine. 293 00:24:14,880 --> 00:24:20,500 As I said earlier, the risk for 51% attacks is in accepting money directly from an attacker. 294 00:24:20,600 --> 00:24:25,280 An attacker will want to find an exchange where it's possible to hide their identity from the exchange. 295 00:24:25,400 --> 00:24:37,500 In the case of Bitcoin Gold, Bitcoin Gold was delisted from Bittrex shortly after the attack, and the Bitcoin Gold dev team put out a statement claiming that Bittrex was a victim of the attack, and that explained their delisting. 296 00:24:37,880 --> 00:24:40,560 I don't know who the victims were of the Vertcoin attack. 297 00:24:40,600 --> 00:24:45,680 In the case of Ethereum Classic, three exchanges all put out statements acknowledging that they were targets. 298 00:24:45,680 --> 00:24:48,080 KYC can help prevent an attack. 299 00:24:49,420 --> 00:24:52,900 Another pattern, the attacks stop after they're publicized. 300 00:24:53,080 --> 00:24:54,540 Cockroaches hate the light. 301 00:24:55,120 --> 00:24:57,240 Bitcoin Gold was a three-day attack. 302 00:24:57,240 --> 00:24:59,200 It was publicized on the third day. 303 00:25:00,780 --> 00:25:03,560 Vertcoin was nearly two months. 304 00:25:03,740 --> 00:25:06,880 The day it was publicized was the day of the last attack. 305 00:25:07,420 --> 00:25:10,480 And Ethereum Classic, also a three-day attack. 306 00:25:10,480 --> 00:25:13,100 The third day was the day it was publicized. 307 00:25:15,060 --> 00:25:17,960 The last pattern I want to talk about is also interesting. 308 00:25:18,640 --> 00:25:23,760 We've noticed that attackers commonly don't place their TNT Prime transactions in the optimal blocks. 309 00:25:23,760 --> 00:25:34,340 Consider the example of the very first Ethereum Classic double spend attack that I talked about before, where 74 blocks did the orphaning of 57 blocks. 310 00:25:35,060 --> 00:25:40,400 This would be the ideal block for an attacker to have placed their transaction T in. 311 00:25:40,400 --> 00:25:46,600 It's the deepest block that was orphaned, which would have given transaction T 57 confirmations at the time of the attack. 312 00:25:47,680 --> 00:25:53,540 Instead, T was placed 13 blocks higher, where it only had 44 confirmations at the time of the attack. 313 00:25:53,600 --> 00:25:56,700 Transaction T was not the deepest orphan block. 314 00:25:56,700 --> 00:26:05,420 That means the attacker did the amount of work required to orphan a transaction with 57 confirmations, but only for a transaction that had 44. 315 00:26:05,720 --> 00:26:10,840 This happens in the vast majority of the double spends that we've observed, which is frankly very puzzling. 316 00:26:12,760 --> 00:26:14,020 So let's review. 317 00:26:14,020 --> 00:26:16,740 I define hacking by attacking the integrity of the blockchain. 318 00:26:16,740 --> 00:26:18,820 New technologies, new ways to hack. 319 00:26:18,840 --> 00:26:26,100 I described a 51% double spend attack, then I walked through real world examples of these attacks, along with the patterns that we've observed. 320 00:26:27,240 --> 00:26:28,360 That concludes my talk. 321 00:26:28,360 --> 00:26:29,540 Does anyone have any questions? 322 00:26:37,380 --> 00:26:37,920 Yeah? 323 00:26:45,110 --> 00:26:47,190 I'm sorry, I can't quite hear you. 324 00:26:52,070 --> 00:26:56,470 Yeah, so I think, let me make sure I'm understanding your question correctly. 325 00:26:56,470 --> 00:26:58,710 When a block is orphaned, is that data lost? 326 00:26:58,830 --> 00:26:59,730 Is that what you're getting at? 327 00:27:09,570 --> 00:27:12,210 Yeah, a node will store that data on its own. 328 00:27:12,210 --> 00:27:18,250 So when a block is orphaned, the node in its database will say this is an orphan block, but it'll hold it. 329 00:27:18,250 --> 00:27:20,230 And so you can still query your node for that data. 330 00:27:20,230 --> 00:27:24,210 Your node had to be around at the time, because those blocks aren't being shared around on the network. 331 00:27:24,210 --> 00:27:26,090 But if your node saw it, your node has it. 332 00:27:27,810 --> 00:27:28,450 Yeah? 333 00:27:28,450 --> 00:27:33,710 So you mentioned that the payout for mining a block is a cost. 334 00:27:34,250 --> 00:27:45,130 It's not exactly, but I think they're probably close, especially in smaller market CapCoins, where general purpose hardware can be moved to arbitrage the mining reward. 335 00:27:49,290 --> 00:27:51,790 This is way more profitable. 336 00:27:52,030 --> 00:28:06,370 If someone is going to take a deposit for a very weak amount of confirmations and give you something incredibly valuable for it, it's just so trivial to claw back the original deposit. 337 00:28:07,430 --> 00:28:09,250 I don't really think they are. 338 00:28:12,830 --> 00:28:17,890 Yeah, well, yes, when they mine their blocks, those are just ordinary nodes. 339 00:28:17,890 --> 00:28:24,450 And the easiest way for them to do it is to not even modify the software, just disconnect it from the internet, mine your block, you create your transactions. 340 00:28:24,450 --> 00:28:31,710 And then once you look locally, you see that you've outpaced the main chain, you just connect to the internet and then the reorg will happen by itself. 341 00:28:33,330 --> 00:28:41,090 So Coinbase has never lost anything in this sort of attack. 342 00:28:41,130 --> 00:28:47,470 We've only seen one attack on an asset that we support, which was the Ethereum Classic attack. 343 00:28:47,470 --> 00:28:51,950 We noticed it immediately because we were monitoring for this and we immediately shut down. 344 00:28:52,810 --> 00:28:58,910 I can't remember the number, there are something like 15 of these reorgs with Ethereum Classic. 345 00:28:58,910 --> 00:29:02,470 The very first one that had a double spend, we alerted and we shut down. 346 00:29:02,470 --> 00:29:06,010 So all the subsequent ones, we're offline and they couldn't have attacked us. 347 00:29:06,430 --> 00:29:11,850 Yeah, but actually there are four different exchanges targeting the ETC 51%. 348 00:29:11,850 --> 00:29:16,410 And actually one of our customers was not that happy because the bank has sent the ETH. 349 00:29:16,410 --> 00:29:25,170 But really the question to you guys is, if you want to withdraw that fiat from Coinbase, it takes quite a bit, right? 350 00:29:25,170 --> 00:29:36,110 And literally, if I am the attacker, how would I cash out or move the fund so that I can cause damage to the exchange? 351 00:29:36,110 --> 00:29:42,070 I don't think that's the case for Coinbase, but under what scenario would that be a damage? 352 00:29:42,270 --> 00:29:45,310 So I'm not sure I understand your question. 353 00:29:45,310 --> 00:29:50,390 I think you're saying if there's a delay on withdrawing from the exchange, that makes it harder to attack the exchange. 354 00:29:50,390 --> 00:29:57,850 And you're definitely correct that if there is a delay in withdrawing the exchange, because then the attack could potentially be detected and before the funds left, you could put a hold on them. 355 00:29:57,850 --> 00:29:59,130 But that's not true in all cases. 356 00:29:59,130 --> 00:30:02,410 You can transfer onto an exchange, sell and transfer off. 357 00:30:02,470 --> 00:30:06,870 And that is a very common pattern without these long delays. 358 00:30:07,770 --> 00:30:10,850 It's one of the pain points for a lot of customers in the cryptocurrency industry. 359 00:30:10,850 --> 00:30:14,330 They don't want to sit and wait for five days for seemingly no reason. 360 00:30:14,470 --> 00:30:17,790 So it's a constant balance to get that number right. 361 00:30:17,790 --> 00:30:21,050 But the faster it is, the better the opportunity for an attacker. 362 00:30:23,030 --> 00:30:24,370 Any other questions? 363 00:30:29,880 --> 00:30:30,820 What's that? 364 00:30:36,070 --> 00:30:38,930 Once the attacker transfers out of Coinbase, it's out of our control. 365 00:30:38,930 --> 00:30:46,610 So then if they can claw back that original send, then they got away with it, essentially, which has never happened to Coinbase, just to be clear. 366 00:30:47,270 --> 00:30:48,610 Any other questions? 367 00:30:52,990 --> 00:30:53,750 All right. 368 00:30:53,750 --> 00:30:54,650 Thank you, everybody.