Who Spent My EOS? On the (In)Security of Resource Management of - - PowerPoint PPT Presentation

who spent my eos on the in security of resource
SMART_READER_LITE
LIVE PREVIEW

Who Spent My EOS? On the (In)Security of Resource Management of - - PowerPoint PPT Presentation

Who Spent My EOS? On the (In)Security of Resource Management of EOS.IO Sangsup Lee , Daejun Kim , Dongkwan Kim, Sooel Son, Yongdae Kim @KAIST 1 Abstract 2K+ Cryptocurrencies 2 Abstract Resource management of EOS.IO 3 Abstract


slide-1
SLIDE 1

Who Spent My EOS?
 On the (In)Security of Resource Management of EOS.IO

Sangsup Lee, Daejun Kim, Dongkwan Kim, Sooel Son, Yongdae Kim @KAIST

  • 1
slide-2
SLIDE 2

2

Abstract

2K+ Cryptocurrencies

slide-3
SLIDE 3

3

Abstract

Resource management of EOS.IO

slide-4
SLIDE 4

4

Abstract

Resource management of EOS.IO 4 unique vulnerabilities

slide-5
SLIDE 5

5

Abstract

Resource management of EOS.IO 4 unique vulnerabilities Evaluated the impact of each vulnerability

slide-6
SLIDE 6

6

Background

slide-7
SLIDE 7

7

Background: Blockchain

Blockchain-based cryptocurrency Consensus Mining P2P Network Wallet Smart contract

Overview of cryptocurrency components

slide-8
SLIDE 8

8

Background: Blockchain

Blockchain-based cryptocurrency Consensus Mining P2P Network Wallet Smart contract

Key components

slide-9
SLIDE 9

9

Background: Blockchain

The fundamentals of blockchain

Data (Block)

slide-10
SLIDE 10

10

Background: Blockchain

Consensus algorithm Creating blocks

Data (Block)

slide-11
SLIDE 11

11

Background: Blockchain

Consensus algorithm Creating blocks Verifying
 blocks

Data (Block)

slide-12
SLIDE 12

12

Background: Blockchain

Consensus algorithm Creating blocks Verifying
 blocks

Data (Block)

Agreement


  • n blocks
slide-13
SLIDE 13

Consensus algorithm (PoW)

13

Numerous block producers

...

Data (Block) Slow… Bitcoin Ethereum

Background: PoW (Proof of Work)

Create Agree

slide-14
SLIDE 14

Background: DPoS (Delegated Proof of Stake)

Elected 21 Block producers (BP) Data (Block)

EOS.IO Consensus algorithm (DPoS)

FAST! (0.5 sec / block)

14

Create Agree

slide-15
SLIDE 15

FAST! (0.5 sec / block) 


But, resource management matters.

15

Elected 21 Block producers (BP) Data (Block)

EOS.IO Consensus algorithm (DPoS)

Background: DPoS (Delegated Proof of Stake)

Create Agree

slide-16
SLIDE 16

16

Resource management necessity

Blockchain

Transaction
 requests User

Background: DPoS (Delegated Proof of Stake)

slide-17
SLIDE 17

17

Resource management necessity

Blockchain

Transaction
 requests User Elected 21 Block producers (BP)

Background: DPoS (Delegated Proof of Stake)

slide-18
SLIDE 18

18

Resource management necessity

Blockchain

Transaction
 requests User Elected 21 Block producers (BP)

Overload problem Properly process request

Background: DPoS (Delegated Proof of Stake) …

slide-19
SLIDE 19

19

Background: Smart contract

$

Alice Bob

Smart contract

Use Case

▪ Exchange ▪ Gambling ▪ Auction ▪ Funding ▪ Bank ▪ And so on. Transaction Transaction Transaction Transaction

slide-20
SLIDE 20

Transaction

▪ Target (Ex. eBay) ▪ Function (Ex. Bidding(), Selling()) ▪ Permission (Ex. Alice@active) $

Alice Bob eBay
 Contract

20

Background: Smart contract on EOS.IO

slide-21
SLIDE 21

$

Alice Bob eBay
 Contract BP Delegated execution

21

Background: Smart contract on EOS.IO

slide-22
SLIDE 22

$

Alice Bob eBay
 Contract BP Delegated execution

22

Background: Smart contract on EOS.IO


 
 Resource management matters Delegated Execution

slide-23
SLIDE 23

Transaction delivery Program execution Data storing

NET CPU RAM

23

Background: Resource of EOS.IO

slide-24
SLIDE 24

Transaction delivery Program execution Data storing

NET CPU RAM Staking

Individuals Blockchain system

Refreshed every day

24

Background: Resource of EOS.IO

slide-25
SLIDE 25

Transaction delivery Program execution Data storing

NET CPU RAM Buy

RAM
 Market

Not refreshed every day.

25

Background: Resource of EOS.IO

Individuals

slide-26
SLIDE 26

26

Why EOS?

slide-27
SLIDE 27

27

2K+ Cryptocurrencies

Market cap #1 #2

Be Selfish and Avoid Dilemmas: Fork After Withholding (FAW) Attacks on Bitcoin
 (ACM CCS ‘17) Publish or perish: A backward- compatible defense against
 selfish mining in bitcoin
 (RSA ‘17) ZEUS: Analyzing Safety of
 Smart Contracts
 (NDSS '18) teether: Gnawing at ethereum to automatically exploit smart contracts
 (USENIX '18) Hijacking bitcoin: Routing attacks on cryptocurrencies 
 (IEEE S&P '17) Eclipse attacks on bitcoin’s peer- to-peer network
 (USENIX ‘15) Making smart contracts smarter
 (ACM CCS '16) The miner's dilemma
 (IEEE S&P '15) Porosity: A decompiler for blockchain-based smart contracts bytecode
 (Defcon '17)

Smart contract
 research Consensus
 research Other research work

Why EOS?

slide-28
SLIDE 28

Rank of 
 marketcap Name Consensus
 algorithm Smart contract platform 1 Bitcoin PoW X 2 Ethereum PoW O 3 Ripple PoS X 4 Litecoin PoW X 5 Bitcoin cash PoW X 6 Binance Coin X X 7 EOS DPoS O

User accounts 1.3 M
 
 But, no security research in academia.

28

Why EOS?

slide-29
SLIDE 29

29

In our paper…

slide-30
SLIDE 30

30

Transaction (SC) Transaction (User)

Block producer

What are new attack targets?

Users

program code

EOS structure

slide-31
SLIDE 31

31

Transaction (SC) Transaction (User)

Block producer

A B

What are new attack targets?

EOS structure

Smart Contract Smart Contract

slide-32
SLIDE 32

32

Transaction (SC) Transaction (User)

Users

Block producer

A B

[ ]@eosio.code

What are new attack targets?

EOS structure

Smart Contract Smart Contract

slide-33
SLIDE 33

33

Transaction (SC) Transaction (User)

Users

Block producer Smart Contract Provider (SCP)

A B

[ ]@eosio.code

=

What are new attack targets?

EOS structure

Smart Contract Smart Contract

slide-34
SLIDE 34

34

Transaction (SC) Transaction (User)

Users

Block producer Smart Contract Provider (SCP)

A B

RAM RAM CPU CPU NET

CPU RAM

NET

CPU RAM

[ ]@eosio.code

=

What are new attack targets?

EOS structure

slide-35
SLIDE 35

35

block creation time

Transaction (SC) Transaction (User)

Users

Block producer Smart Contract Provider (SCP)

A B

CPU RAM CPU RAM

[ ]@eosio.code

=

What are new attack targets?

Attack Target

RAM RAM CPU CPU NET NET

slide-36
SLIDE 36

36

What are new attack targets?

Transaction (SC) Transaction (User)

Users

Block producer Smart Contract Provider (SCP)

A B

CPU RAM CPU RAM

[ ]@eosio.code

=

Pay for transaction

block creation time

RAM RAM CPU CPU NET NET

Attack Target

slide-37
SLIDE 37

37

Transaction (SC) Transaction (User)

Users

Block producer Smart Contract Provider (SCP)

A B

CPU RAM CPU RAM

[ ]@eosio.code

=

Pay for transaction To save data What are new attack targets?

block creation time

RAM RAM CPU CPU NET NET

Attack Target

slide-38
SLIDE 38

38

grant permission to SCP

Transaction (SC) Transaction (User)

Users

Block producer Smart Contract Provider (SCP)

A B

CPU RAM CPU RAM

[ ]@eosio.code

=

Pay for transaction What are new attack targets?

block creation time

RAM RAM CPU CPU NET NET

Attack Target

To save data

slide-39
SLIDE 39

39

We found …

Transaction (SC) Transaction (User)

Users

Block producer Smart Contract Provider (SCP)

A B

CPU RAM CPU RAM

[ ]@eosio.code

=

Attack Models & Threat Models & Attacks!

RAM RAM CPU CPU NET NET

slide-40
SLIDE 40

40

We found …

Block delay attack

Transaction (SC) Transaction (User)

Users

Block producer Smart Contract Provider (SCP)

A B

CPU RAM CPU RAM

[ ]@eosio.code

=

Attack Models & Threat Models & Attacks!

RAM RAM CPU CPU NET NET

slide-41
SLIDE 41

41

We found …

Transaction (SC) Transaction (User)

Users

Block producer Smart Contract Provider (SCP)

A B

CPU RAM CPU RAM

[ ]@eosio.code

=

Attack Models & Threat Models & Attacks!

Block delay attack CPU-Drain attack

RAM RAM CPU CPU NET NET

slide-42
SLIDE 42

42

We found …

Transaction (SC) Transaction (User)

Users

Block producer Smart Contract Provider (SCP)

A B

CPU RAM CPU RAM

[ ]@eosio.code

=

RAM-Drain attack

Attack Models & Threat Models & Attacks!

Block delay attack CPU-Drain attack

RAM RAM CPU CPU NET NET

slide-43
SLIDE 43

43

We found …

Attack Models & Threat Models & Attacks!

Transaction (SC) Transaction (User)

Users

Block producer Smart Contract Provider (SCP)

A B

CPU RAM CPU RAM

[ ]@eosio.code

=

RAMsomware attack Block delay attack RAM-Drain attack CPU-Drain attack

RAM RAM CPU CPU NET NET

slide-44
SLIDE 44

44

Attack

slide-45
SLIDE 45

45

Transactions (trx)

Succeeded state Exhausted state Timer (T)

Block producer

Queue Block

Block delay attack | DoS by draining EOS resources | RAMsomware attack

0.5s 0.5s

Block delay attack

slide-46
SLIDE 46

46

T+0.5s

Transactions (trx)

Succeeded state Exhausted state T+0.5s Timer (T) T+0.5s T+0.5s T+0.5s

Block producer

Queue Block

Block delay attack | DoS by draining EOS resources | RAMsomware attack

Block delay attack

slide-47
SLIDE 47

47

T+0.5s

Transactions (trx)

T+0.5s Timer (T) T+0.5s T+0.5s T+0.5s

Block producer

Block delay attack | DoS by draining EOS resources | RAMsomware attack

Succeeded state Exhausted state Queue Block

T+0.2 +0.2 +0.2 +0.2 +0.2

Block delay attack

slide-48
SLIDE 48

48

T+0.5s

Transactions (trx)

T+0.5s Timer (T) T+0.5s T+0.5s T+0.5s

Block producer

Block delay attack | DoS by draining EOS resources | RAMsomware attack

Succeeded state Exhausted state Queue Block

T+0.2 +0.2 +0.2 +0.2 +0.2

Block delay attack

slide-49
SLIDE 49

49

Block delay attack | DoS by draining EOS resources | RAMsomware attack

T+0.5s

Transactions (trx)

Succeeded status Exhausted status T+0.5s Timer (T) T+0.5s T+0.5s T+0.5s

A

Block producer

Block Queue

SC1 Action (sc) Action (sc) SC2 Action (sc) Action (sc) SC3 Action (sc) Action (sc) SC4 Action (sc) Action (sc) SC5 Action (sc) Action (sc) SC6 Action (sc) Action (sc) SC7 Action (sc) Action (sc)

transaction Call(A) transaction Call(A)

A

Block delay attack

slide-50
SLIDE 50

50

Block delay attack | DoS by draining EOS resources | RAMsomware attack

send_deferred (A)

Timer (T) T+0.5s T+0.5s T+0.5s

B

Queue

Block producer

Block

N

send_deferred (A) send_deferred (A)

T+0.2 +0.2 +0.2 +0.2 +0.2 +0.2 * x

Transactions (trx)

Succeeded state Exhausted state T+0.5s

0.5*x - 0x2*x Block creation delay time

real time : T = T+ 0.2 * x Expected time T = T+0.5*x

Block delay attack

slide-51
SLIDE 51

Attacker Victim Block Count Time (min) Eos-CPU (min) EOS-NET (MiB) Cost (EOS) Delay Time (min) Loss (EOS) 376 0.92 1.23 16.13 480 2.05 40,802 704 2.06 2.32 34.72 910 3.56 70,856 1106 3.02 3.65 50.82 1,426 5.67 112,851 1471 4.00 4.85 65.53 1,894 7.46 148,478 1840 5.04(min) 6.07 79.69 2,368 9.12(min) 181,518

51

Block delay attack | DoS by draining EOS resources | RAMsomware attack

181,518 EOS == $880,000 USD

(29/7/2019)

Average of EOS transfer volume (01/04/2019~30/04/2019)

Block delay attack

Estimated financial loss via block delay attack

slide-52
SLIDE 52

Attacker Victim Block Count Time (min) Eos-CPU (min) EOS-NET (MiB) Cost (EOS) Delay Time (min) Loss (EOS) 376 0.92 1.23 16.13 480 2.05 40,802 704 2.06 2.32 34.72 910 3.56 70,856 1106 3.02 3.65 50.82 1,426 5.67 112,851 1471 4.00 4.85 65.53 1,894 7.46 148,478 1840 5.04(min) 6.07 79.69 2,368 9.12(min) 181,518

52

Block delay attack

Block delay attack | DoS by draining EOS resources | RAMsomware attack

표의 맨 아래쪽을 보면 5분동안 dummy transaction을 잔류 시키면, 약 9분간 block이 생성이 멈추는 결과를 얻을 수 있었다. block 생성이 멈추면 EOS 의 모든 transaction 처리가 되지 않으며, 그 잠재적 손실은 191,518 EOS 이다.

Estimated financial loss via block delay attack

We get maximum bug bounty ($10,000 USD) From EOSIO foundation

slide-53
SLIDE 53

53

Block delay attack | DoS by draining EOS resources | RAMsomware attack

Block producer

A

SAVE_DATA ram-payer =_self

Users

EOS-CPU: 1,000 ms EOS-RAM: 0.0 MB EOS-NET: 1,000 bps

EOS-RAM is purchase resource not stake, so EOS-RAM doesn’t return until finishing their propose

DoS by draining EOS resources: RAM-drain attack

slide-54
SLIDE 54

54

Block delay attack | DoS by draining EOS resources | RAMsomware attack

Block producer

A

SAVE_DATA ram-payer =_self

Users

EOS-CPU: 1,000 ms EOS-RAM: 1 MB EOS-NET: 1,000 bps EOS-CPU: 1,000 ms EOS-RAM: 1 MB EOS-NET: 1,000 bps

EOS-CPU: 1,000 ms EOS-RAM: 0.0 MB EOS-NET: 1,000 bps

EOS-RAM is purchase resource not stake, so EOS-RAM doesn’t return until finishing their propose

DoS by draining EOS resources: RAM-drain attack

slide-55
SLIDE 55

RAM (MiB) 4 8 12 16 20 3 6 9 12 15 18 21 24 27 30 Attack N Attack 2^N RAM (MiB) 0.4 0.8 1.2 1.6 2 Second (s) 1 2 3 4 5

SCA SCB

55

Block delay attack | DoS by draining EOS resources | RAMsomware attack

The Consuming time for RAM is depends on Smart contract’s source code

20MiB 30s

1MiB == $ 402 USD

DoS by draining EOS resources: RAM-drain attack

slide-56
SLIDE 56

56

A

Create new transaction

Users

EOS-CPU: 1,000 ms EOS-RAM: 1 MB EOS-NET: 1,000 bps

EOS-CPU: 1,000 ms EOS-RAM: 1 MB EOS-NET: 1,000 bps EOS-CPU: 500 ms EOS-RAM: 1 MB EOS-NET: 500 bps

Block delay attack | DoS by draining EOS resources | RAMsomware attack

DoS by draining EOS resources: CPU-drain attack

B

slide-57
SLIDE 57

57

A

Create new transaction

Users

EOS-CPU: 700 ms EOS-RAM: 1 MB EOS-NET: 700 bps

EOS-CPU: 0 ms EOS-RAM: 1 MB EOS-NET: 0 bps

Block delay attack | DoS by draining EOS resources | RAMsomware attack

<

Cost {EOS-CPU of $B} + Cost {EOS-NET of $B} Cost {EOS-CPU of $A} + Cost {EOS-NET of $A}

DoS by draining EOS resources: CPU-drain attack

B

slide-58
SLIDE 58

58

Attacker Victim SC provider Attack Count EOS-NET (KiB) Eos-CPU (ms) EOS-NET (KiB) EOS-CPU (ms) 1 0.137 0.146 3.562 0.400 10 1.329 1.485 3.555 4.366 20 2.655 2.938 3.549 8.352 50 6.626 7.422 3.534 20.47 100 13.21 15.23 3.509 41.19

Block delay attack | DoS by draining EOS resources | RAMsomware attack

Attacker partially make DoS to victim while a day

Over x3 (times)

DoS by draining EOS resources: CPU-drain attack

slide-59
SLIDE 59

59

Block delay attack | DoS by draining EOS resources | RAMsomware attack

Block producer

Users

Give EOSIO.CODE

Normal Action

B A

Call(B)

RAMsomware attack

slide-60
SLIDE 60

60

Users

Smart Contract Provider (SCP)

A A

CPU RAM CPU RAM

RAM RAM CPU CPU NET NET

[User]@eosio.code [User]@eosio.code

RAMsomware attack

slide-61
SLIDE 61

61

Block delay attack | DoS by draining EOS resources | RAMsomware attack

Block producer

Users

User EOS-RAM is drained Attacker demand ransom of EOS-RAM to the victim

JUST SEND TRANSACTION

Call(A)

A A

Call(A)

loop

SAVE DATA

Use EOS-RAM

RAMsomware attack

slide-62
SLIDE 62

62

RAMsomware attack

Block delay attack | DoS by draining EOS resources | RAMsomware attack

The user who have the largest EOS-RAM have 2GB EOS RAM

RAM (MiB) 400 800 1200 1600 2000 Seconds (s) 2 4 6 8 10 12 14 16 18 20 22

2GiB 22s

2GB EOS-RAM == $ 800,000 USD

slide-63
SLIDE 63

63

Defense

slide-64
SLIDE 64

64

  • Block delay attack
  • CPU/RAM drain attack
  • RAMsomware attack

Defense

Trivial solution

  • Patched by EOSIO developers
  • Do access control
  • Do check smart contract version
slide-65
SLIDE 65

65

  • Block delay attack
  • CPU/RAM drain attack
  • RAMsomware attack

Defense

  • Fine graind permission

: eosio.code Expire Time, Maximum EOS Coin per a transaction : EOS-CPU permission, EOS-NET permission, EOS-RAM permission etc…

  • Totally payment of transaction fee to the first transaction creator

: Every transaction that purpose a role, is payed by the users who start trx.

Trivial solution Design solution

  • Patched by EOSIO developers
  • Do access control
  • Do check smart contract version
slide-66
SLIDE 66

66

Conclusion & Future work

  • Conclusion
  • Analyzed new threats from the view point of new resources in EOS.IO
  • Found 4 new attack methodologies and verified them
  • Proposed new security features to prevent our attacks
  • Future work
  • Make an automatic auditing tool for our attacks
  • Design a web assembly analyzer
slide-67
SLIDE 67

67

Thank you

{k1rh4, reset, dkay, sl.son, yongdaek}@kaist.ac.kr