Cryptocurrencies Course: EPL682 Advanced Security Topics - - PowerPoint PPT Presentation

cryptocurrencies
SMART_READER_LITE
LIVE PREVIEW

Cryptocurrencies Course: EPL682 Advanced Security Topics - - PowerPoint PPT Presentation

Cryptocurrencies Course: EPL682 Advanced Security Topics Instructor: Elias Athanasopoulos SoK: Research perspective and challenges for Bitcoin and cryptocurrency Joseph Bonneau , Andrew Miller , Jeremy Clark, Arvind Narayanan


slide-1
SLIDE 1

Cryptocurrencies

Course: EPL682 – Advanced Security Topics Instructor: Elias Athanasopoulos

slide-2
SLIDE 2

SoK: Research perspective and challenges for Bitcoin and cryptocurrency

Joseph Bonneau∗†‡, Andrew Miller§ , Jeremy Clark¶, Arvind Narayanan∗ , Joshua A. Kroll∗ , Edward W. Felten∗ ∗Princeton University, †Stanford University, ‡Electronic Frontier Foundation, §University of Maryland, ¶Concordia University

Systematization of Knowledge Papers Suitable papers are those that provide an important new viewpoint on an established, major research area, support or challenge long-held beliefs in such an area with compelling evidence, or present a convincing, comprehensive new taxonomy of such an area. www.ieee-security.org

slide-3
SLIDE 3

Terms

Blockchain A blockchain, is a growing list of records, called blocks, that are linked using

  • cryptography. Each block contains a cryptographic hash of the previous block, a

timestamp, and transaction data (generally represented as a Merkle tree). “In Bitcoin, the log is implemented as a series of blocks of transactions, each containing the hash of the previous block, committing this block as its sole antecedent. It is referred to as the blockchain.“ Proof-of-Work A proof-of-work (PoW) system (or protocol, or function) is a consensus

  • mechanism. It deters denial-of-service attacks and other service abuses such

as spam on a network by requiring some work from the service requester, usually meaning processing time by a computer.

slide-4
SLIDE 4
slide-5
SLIDE 5

Bitcoin wallet

Cryptocurrency wallet Comparable to a bank account, contains a pair of public and private cryptographic keys. A public key allows for other wallets to make payments to the wallet's address, whereas a private key enables the spending of cryptocurrency from that address.

slide-6
SLIDE 6

Ερευνα στο Bitcoin

  • Γιατί είναι σημαντικό το Bitcoin και τις προκλήσεις του
  • Without any trusted parties
  • Without pre-assumed identities among the participants
  • Το βασικό πρωτόκολλο συναίνεσης του Bitcoin έχει επίσης σημαντικές συνέπειες

για πολλά άλλα προβλήματα ασφάλειας υπολογιστών πέρα από το νόμισμα, όπως

  • distributed naming,
  • secure timestamping and commitment,
  • generation of public randomness,
  • financial problems such as self-enforcing (“smart”) contracts,
  • decentralized markets and order books,
  • distributed autonomous agents.
slide-7
SLIDE 7

Γιατί αξίζει να το μελετήσουμε

  • “Bitcoin works in practice, but not in theory.”
  • Ενώ το Bitcoin έχει μέχρι στιγμής δουλέψει με εκπληκτικό τρόπο, υπάρχει ένας σημαντικός

ρόλος της έρευνας να διαδραματίσει για να εντοπίσει ακριβώς γιατί αυτό ήταν δυνατό

  • Η ερευνητική κοινότητα ασφαλείας αποφεύγει να χρησιμοποιήσει το Bitcoin, χωρίς να

αναγνωρίζει αμέσως την καινοτομία του, και ακόμα σήμερα το απορρίπτει λόγω της έλλειψης αυστηρών θεωρητικών θεμελίων.

  • Ο στόχος μας είναι να τονίσουμε και τους πολλούς τομείς στους οποίους έχει ήδη

σημειωθεί σημαντική καινοτομία, από πρωτότυπα πρωτόκολλα πληρωμών μέχρι φιλικά προς το χρήστη διαχείριση κλειδιών (payment protocols to user-friendly key management), καθώς και τις πιο σημαντικές ανοικτές ερευνητικές προκλήσεις για το Bitcoin και τα μελλοντικά κρυπτοσυστήματα.

slide-8
SLIDE 8

Ιστορία του Bitcoin

  • Cryptographic currencies date back to Chaum’s proposal for “untraceable payments”

in 1983

  • Ηθελε από την τραπεζα να εκδοθουν μετρητα σε τυφλα υπογραμμενα κερματα

(blindly signed coin).

  • Θα ελεγχε μονο άν το blind coin έχει χρησιμοποιηθεί προηγουμένως. Δεν σύνδεε

τον λογαριασμο με κάποια οντότητα

  • Τα τυφλά νομίσματα μεταφέρονται μεταξύ χρηστών και εμπόρων και μπορούν να

εξαργυρωθούν αφού η τράπεζα επιβεβαιώσει ότι δεν έχουν εξαργυρωθεί προηγουμένως.

  • Καποιες εταιρίες ξεκίνησαν όπως η DigiCash Και Peppercoin χωρίς να προχωρίσουν
  • Ακολούθησαν πολλές άλλες εφαρμογές, συμπεριλαμβανομένων προτάσεων για

δίκαιη λαχειοφόρο αγορά (fair lottery)

slide-9
SLIDE 9

Ιστορία του Bitcoin

  • Το Proo
  • of-of
  • f-work χρησιμοποιήθηκε επίσης για την ανίχνευση των sybil κόμβων σε

κατανεμημένα πρωτόκολλα συναίνεσης μεταξύ ομότιμων, παρόμοια με την τρέχουσα χρήση της στη συναίνεση Bitcoin.

  • Το pub

publi lic led edger, το οποίο καθιστά τις διπλές δαπάνες ανιχνεύσιμες.

  • Το B-money, που προτάθηκε το 1998, φαίνεται να είναι το πρώτο σύστημα όπου όλες οι

συναλλαγές είναι δημόσια (αν και ανώνυμα).

  • Το 2008

2008, ανακοινώθηκε το Bitcoin και μια λευκή βίβλος με το ψευδώνυμο Satoshi Nakamoto.

  • Το Block gen

enesis του Bitcoin in εξήχθη στις στις 3 Ιανουαρίου 2009. Η πρώτη χρήση του Bitcoin ως νομίσματος θεωρείται συναλλαγή τον Μάιο του 2010, όπου ένας χρήστης διέταξε την παράδοση πίτσας σε άλλο αντί για 10.000 bitcoins.

  • Η ιστοσελίδα της μαύρης αγοράς Silk

lk Roa

  • ad χρησιμοποιούσε Bitcoin μέχρι που έκλεισε.
  • Το 2014, ένας υπολογιστικός ιός που ονομάζεται CryptoLocker εξήγαγε εκατομμύρια

δολάρια από τα θύματα, κρυπτογραφώντας τα αρχεία τους και ζητώντας Bitcoin.

slide-10
SLIDE 10

Τα τρία βασικά τεχνικά στοιχεία του Bitcoin

1.

  • 1. Tran

ansactions an and scr scrip ipts 2.

  • 2. Con
  • nsensus

s an and min inin ing 3.

  • 3. Peer-to

to-peer communication network

slide-11
SLIDE 11

Bitcoin Transaction

Transaction Fee: Οποιοδήποτε Bitcoin εισόδου που δεν εξαργυρώνονται σε μια έξοδο θεωρείται τέλη συναλλαγής (transaction fee). Oποιος δημιουργεί το blog (miner) μπορεί να το διεκδικήσει εισάγοντάς το στη συναλλαγή νομισμάτων (coinbase transaction) αυτού του blog.

  • 10^8 satoshis = 1 bitcoin.
  • Input/output arrays.
  • Hashed using SHA-256 (unique trans. ID).
  • Transaction fee = Input Value – Output Value
slide-12
SLIDE 12

Bitcoin Transaction

“ In addition to the requirements that each transaction input matches a previous transaction output and that the two scripts execute successfully”

slide-13
SLIDE 13

Consensus

“Nakamoto consensus. This can be considered Bitcoin’s core innovation and perhaps the most crucial ingredient to its success.”

  • Παίρνουμε σαν σωστό το τι θα αποφασίσει η πλειοψηφία
  • Nakamoto Consensus = Proof of Work
  • Μια ομαδα κανονων
  • Δουλεία των mıners
  • Το Blockchaın μπορεί να έχει πολλά fork αλλα κάπια στιγμή θα κερδίσει αυτό με τα

περισσότερα blog. Μεχρι τα 6 blog το θεωρουμε confirmed (μπορει και όχι-de deep ep fork

  • rk)
  • “In the worst case, this can effectively enable a double spending attack”
  • Το Proof-of-Work μας προστατεύει από DoS attacks και λόγο της τυχαιότητας του

προβλήματος θα έχουμε πάντα μεγαλύτερο fork γιατί άλλος θα κερδίζει κάθε φορά.

  • Ta Deep forks αποφεύγονται από τα checkpoınts
slide-14
SLIDE 14

Mining

  • Μining ειναι η διεργασία όπου πολλες μηχανες ψάχνουν να λύσουν εναν Puzzle-PoW
  • Ανταμήβονται χρηματικα
  • Μπαινει ενα μπλοκ καθε 10 λεπτα
  • Block size – 1MB
  • Hashing Algorithm SHA-256

Πως ανταμειβωνται οι miners

  • Fix-scheduled (From 50BTC, 25BTC…)
  • Transaction fee (difference between Input and Output)
  • Penny-flooding (1-2% ) of mining revenue
slide-15
SLIDE 15

Peer-to-Peer Communication Network

  • Να λαμβανουν πολλα αλλα να μην σέλνουν πολλα
  • Το latency του δυκτίου έχει σημαντικο επακολουθο στο consensus

First, any la latency between the discovery of a block and its receipt by all other nodes increases the possibility of a tem emporary ry fork… Second, a mal alic icious min iner er who is able to control a substantial portion of the network may attempt to favor the broadcast of their own blocks.”

slide-16
SLIDE 16

Stability of the consensus protocol

  • Eventual con
  • nsensus – all compliant nodes will agree upon a prefix of what will become the

eventual valid blockchain.

  • Ex

Exponentia ial convergence – the probability of a fork of depth is O(2−n). This gives users high confidence that a simple “k confirmations” rule will ensure their transactions are permanently included with high confidence.

  • Liveness – new blocks will continue to be added and valid transactions with appropriate fees

will be included in the blockchain within a reasonable amount of time

  • Corr
  • rrectn

tness – all blocks in the longest chain will only include valid transactions

  • Fair

irness – on expectation, a miner with a proportion of the total computational power will mine a proportion of blocks. “If all of these properties hold we can say that the system is stable, but it isn’t clear that all are necessarily required.”

slide-17
SLIDE 17

Stability

Παραγοντες που καταπατουν το Faırness

  • Κόμβοι με γρηγορότερο δίκτυο ή με περισσότερη υπολογιστική δύναμη
  • Κομβοι όπου συνεργαζονται μεταξύ τους-mining pools. (Cartels which collectively have over

51% of the mining power).

  • Stabılıty ıs not known as mınıng rewards declıne
  • Wıth a majorıty miners stabılıty ıs not guaranteed (makes hıs own blockchaın and gets all

reward) Mınıng poo

  • ols
  • Τείνουν να μην επιτήθωνται μεταξύ τους
  • Δεν αναμένονταν συμφωνα με το επίσημο έγγραφο

Attac acks

  • Goldfınger attack (51% attack - Gash.IO maining pool exceeded 50% July 2014)
  • Feather-forkıng attack
slide-18
SLIDE 18

Client-Side Security

  • Simplified Payment Verification (SPV) Security
  • Problem: Mobile Devices will be slow if all Public Ledger is installed
  • Solution: Only need to validate the Proof-Of-Wok and trust the longest chain (correctness property)
  • Key Management
  • Keys stored on device.
  • Split control.
  • Password-protected wallets.
  • Password-derived wallet.
  • Offline storage.
  • Air-gapped and hardware storage.
  • Hosted wallet(web service key management).
slide-19
SLIDE 19

Upgrading Bitcoin

  • New Forms of Bitcoin
  • Hard forks. eg Bitcoin cash
  • Soft forks.
  • Relay policy updates.
  • Altcoins
  • New genesis block.
  • Forking Bitcoin.
  • Proof-of-burn – deposit coins into an null wallet (has of all zeros, no private key)
  • Pegged sidechains – Soft fork in a way
slide-20
SLIDE 20

Alternative Consensus Protocol

  • Parameter changes
  • Inter-block time and difficulty adjustment window – 10 minutes
  • Limits on block and transaction size - 1 MB - transaction volume with the set block size is 7 per

second, 1000 times slower than peak Visa transactions.

  • Monetary Policy - Νομισματική πολιτική
  • Alternative computational puzzles
  • ASIC – resistant puzzles
  • Useful puzzles
  • Non-outsourceable puzzles
  • Virtual Mining – Proof-of-Stake
  • Designated Authorities
slide-21
SLIDE 21

Anonymity & privacy

  • Οι χρήστες μπορούν να δημιουργήσουν διευθύνσεις όποια δίποτε στιγμή
  • Με το public ledger υπάρχουν τρόποι να ανιχνεύσεις τις συναλλαγές με την

διεύθυνση

  • Για την πλήρη ανωνυμία ο κάτοχος πρέπει να κάνει κάποια βήματα
  • Άλλοι τρόποι Mix network
  • Πολλοί χρήστες αναμειγνύουν τα κέρματά τους μαζί σε ένα μεγάλο δοχείο
  • Κάθε χρήστης θα λάβει μικροδιαπραγματεύσεις σε αντάλλαγμα που θα ήταν

εξαιρετικά δύσκολο να εντοπιστεί

slide-22
SLIDE 22

Anonymity & privacy

Proposals for improving anonymity:

  • Peer to Peer
  • Distributed mix network
  • Altcoins with integrated unlinkability
slide-23
SLIDE 23

Extending Bitcoin’s Functionality

  • Atomicity – atomic transactions
  • Collateral – deposit only refunded in the case of correct behavior
  • Auditability – dishonest part
slide-24
SLIDE 24

Conclusion

  • Bitcoin is not flawless
  • Unclear stability and efficiency
  • Practice seems to be ahead of theory
  • This is a rich space which has a lot of research potential
  • There are several open questions
slide-25
SLIDE 25

TEETHER: Gnawing at Ethereum to Automatically Exploit Smart Contracts

Johannes Krupp CISPA, Saarland University, Saarland Informatics Campus Christian Rossow CISPA, Saarland University, Saarland Informatics Campus

slide-26
SLIDE 26

Introduction

  • Ethereum Virtual Machine (EVM) distributed computing
  • Smart Contracts are programs written in Solidity
  • Touring-Complete Machine
  • Ether cryptocurrency coin
  • 1ETH = 10^8 Wei
slide-27
SLIDE 27

Smart Contracts

  • Nodes are rewarded to run Smart Contract executed on incoming transaction (gas)
  • Like regular programs has: address, balance
  • Ether is Statefull. Any change on one node being to others
  • Smart Contracts – δεν αλλαζουν αρα αυξανεται το ρίσκο για bugs
  • Smart Contracts – είναι μια στοίβα από εντολές που εκτελούνται για να γίνει η

συναλλαγή

  • Smart contracts - μπορούν να δημιουργηθούν με την αποστολή μιας ειδικής

συναλλαγής στη zero address (String of bytecode on EVM). Μετά τη δημιουργία, ο κώδικας μιας σύμβασης είναι αμετάβλητος

slide-28
SLIDE 28

Transactions

Var aria iable les Des escrip iptio ion fr from

  • m

sender to to recipient val alue transferred amount(Wei 10^-18 Ether) - may also be zero gas as “transaction fee“ da data input data - may be empty

Invoked once at the start. Initialize ‘owner’ with message sender Checks if the sender of the transaction is equal to the stored owner of the wallet

slide-29
SLIDE 29

Ethereum Virtual Machine (EVM)

  • stack machine – Turing Complete
  • 256 bit wordsize
  • ~70 instructions opcodes (Like ISA)
  • arithmetic
  • logic
  • control flow
  • blockchain interaction1
  • Sm

Smart Con

  • ntract executed for each
  • transaction. There are the rules of

transaction

  • Sm

Smart Con

  • ntract may contain bugs.
  • Smart Con
  • ntract cannot be updated
slide-30
SLIDE 30

Challenges

  • Control Flow Graph recovery
  • Contract state
  • SHA3 instruction
slide-31
SLIDE 31

CFG-recovery

  • Control Flow Instructions

Com

  • mmand

Inp Inputs Des escrip iptio ion JUMP target Uncoditional jump to target JUMPI target, test Conditional jump. Jump to target if test is non-zero JUMPDEST N/A Marks valid jump target

slide-32
SLIDE 32

Critical Instructions

Ins Instru ructio ion Inp Input Des escrip iptio ion CALL To, value Regular transaction, transfer “value” to “to” SELFDESTRUCT Recipient Contact destruction and transfer funds to recipient CALLCODE/DELEGATECALL Target Execute code of target “code injection”

slide-33
SLIDE 33

Critical path

  • Ενα contract ειναι σε critical path αν ενα transaction μπορει να

1. Τρεξει ενα CALL ή SELFDESTRUCT 2. Τρεξει ένα CALLCODE ή DELEGATECALL

  • Για να βρουμε το Crit

ritic ical Path th πρεπε: 1. Να βρουμε τα Critical Instructions 2. Να υπολογίσουμε απο πια πεδία πρωέρχεται 3. Να φιλτραρουμε τα attacker controlled πεδία 4. Να δήμιουργήσουμε ένα μονοπάτι μεσο αυτών των πεδίων (path) 5. Εκτελώ το μονοπατι βλεποντας τους περιορισμούς (path Constraints) 6. Χρησιμοποιειώ Constraint Solver (A*) για να βρει την βελτιστη λύση

34

slide-34
SLIDE 34

Path Generation

Dependent edges Return address

  • Για να βρεε το Critical Path, ο TeEther

χρησιμοποιεί A*

  • Οταν βρεθεί το Path τοτε το Path

Constraint Generation Module τρέχει χρησιμοποιώντας Ζ3 symbolic execution engine για να πιασει ολα τα Path Constraints.

slide-35
SLIDE 35

Constraint Generation

  • Καποια μονοπατια ειναι μη

προσβασιμαΑκατόρθωτα μονοπάτια

  • Hash Computation - Symbolic translation

υπολογίζεται απο Keccak-256

  • Symbolic-Length Memory Access
  • Constraint results

P is tuple

slide-36
SLIDE 36

Exploit Generation

  • Exploiting Transactions
  • Path constraint check with kaccak-256
  • Use of Z3 constraint solver
slide-37
SLIDE 37

Contract State

1. 1. Criti itical l Path. A critical path is a potential execution trace that either CALL SELFDESTRUCT CALLCODE DELECGATECALL 2. 2. State Cha Changing P

  • Path. A state changing path is a

potential execution trace that contains at least one SSTORE RE instruction. 3. 3. State Cha hanging Tran

  • ansaction. A transaction is state

changing if its execution trace is a state changing path. 4. 4. Vul ulnerable State. A contract is in a vulnerable state, if a transaction can lead to the execution of a critical path. 5. 5. Vul ulnerable(3+ (3+4). ). A contract is vulnerable if there exists a (possibly empty) sequence of state changing transactions that lead to a vulnerable state. Successful exploit = sequence of state e cha changing tr transactions by cr crit itical l tr transa sactio ion

slide-38
SLIDE 38

Evaluation

  • Κατεβασαν στιγμιοτυπα του Ethereum blockchain
  • Σαρωησαν 784344 smart contracts
  • Διαγραψαν τα δυπλα-Καποια είχαν το ίδιο bytecode
  • 38757 μοναδικα
  • 32401 single-address
  • Intel Xeon E5-2660, 192GB RAM (max 32GB used)
  • 30 min CFG recovery
  • 30 min exploit generation
slide-39
SLIDE 39

Results

slide-40
SLIDE 40

Validation

  • Συγκεκριμένος αριθμος Ether σε καθε λογαριασμο
  • 3 accounts:
  • Target contract
  • Attacker
  • Shellcode contract
  • Two step validation
slide-41
SLIDE 41

Vulnerabilities

  • Logic bugs
  • Semantic Confusion
  • Visibility errors
  • Constructor errors
slide-42
SLIDE 42

Conclusion

  • Χαμηλη ασφαλεια των Smart Contracts
  • Αυτοματοποιηση Exploits
slide-43
SLIDE 43

THANK YOU