minimum failure - i.blackhat.com · wallet.fail •vulnerabilities on several bitcoin wallets....

53
MINimum Failure Stealing Bitcoins with Electromagnetic Fault Injection Colin O’Flynn C.T.O., NewAE Technology Inc. Assistant Professor, Dalhousie University 1

Upload: others

Post on 18-Oct-2019

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

MINimum Failure

Stealing Bitcoins with

Electromagnetic Fault InjectionColin O’Flynn

C.T.O., NewAE Technology Inc.

Assistant Professor, Dalhousie University1

Page 2: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

My Dual Life

• C.T.O @ NewAE Technology Inc.• NewAE produces embedded tooling for hardware security validation.

• 700+ customers in 44 countries.

• Started the open-source ChipWhisperer project.

• Assistant Professor @ Dalhousie University• Part of Electrical & Computer Engineering Dept.

• Working on cybersecurity research + with local embedded startups.

2

Page 3: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

The Talk With it All!! In no particular order:

• A true history of block chain!

• Me gambling with 0.3 BTC!

• Physical give-aways!

• Attacking bitcoin wallets & stealing funds!

• Stealing authentication credentials!

• Crass commercialization!

• Open-Source tool release!

• Fixing your crappy code!

3

Page 4: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Blockchain Background (1/2)

4

Page 5: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Blockchain Background (2/2)

5

Page 6: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Example: Blockchain Secures Voting Booth

6

Page 7: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

History

• May 11, 2008: First concrete implementation.

(H. Simpson)

• Oct 31, 2008: More well-known computer implementation.

(S. Nakamoto)

7

Page 8: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

• A true history of block chain!

• Me gambling with 0.3 BTC!

• Physical give-aways!

• Attacking bitcoin wallets & stealing funds!

• Stealing authentication credentials!

• Crass commercialization!

• Open-Source Tool Release!

• Fixing your crappy code!

8

Page 9: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Let’s Embed Those Blockchains

9

Page 10: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Why a Hardware Wallet?

10

Vaguely Trusted Computer 1

Vaguely Trusted Computer 2

Hardware Wallet

• Hardware wallet shows what actual request is (display).• Hardware wallet signs request.• Hardware wallet prevents read-out of “private key” used

to sign any request.

Page 11: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Trezor Features

11

Page 12: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Example: Ultrasonic Seal

<Hopefully my camera works>

12

Page 13: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Why Pick on Trezor?

• Trezor is Open Source• Anyone can validate the source code, modify it, etc.• Lessons learned on Trezor can be applied outside of

bitcoin wallets.• Embedded systems, IoT, automotive, etc.

•This problem I’m disclosing has been fixed with issued firmware patch.

13

Page 14: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

About Bitcoin Recovery Seeds

From Trezor documentation:

Important Caveat: You can also password-protect this seed, but it’s not done by default. If password protected, the attacks I’m going to describe don’t work!

14

Page 15: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

What’s inside the Trezor?

15

Page 16: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

How to Get Recovery Seeds?

16

Page 17: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Wallet.Fail

• Vulnerabilities on several Bitcoin Wallets.

• For Trezor specifically:• How to copy recovering seed out of a backup stored in SRAM.

• Required physical access to PCB (open enclosure), but can be performed with high reliability.

17

Page 18: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

My Inspiration – Wallet.Fail Talk

18

Page 19: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

How else to get recovery seed?

19

Page 20: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Recovery seed, device PIN saved here!

What’s going on up in here?

20

Page 21: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

USB Descriptors

21

Page 22: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

wLength→ Host Provided Max Request Size

22

Page 23: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Send MIN() of wLength & Struct Length

23

Page 24: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Checking Implementation Details

24

Page 25: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Open Source FTW :)

• I can be lazy since firmware is fully known & I can modify it even.

• We can ‘simulate’ the glitch to ensure things will work as we expect.

25

Page 26: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Validating This Will Work (1/2)

Expected response (146 bytes)

Use debugger to skip MIN() check.

26

Page 27: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Validating This Will Work (2/2)

27

Page 28: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Generated and Induced Magnetic Field

28

Page 29: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Example of Coils

29

Page 30: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

EMFI SetupForce bootloader mode.

EMFI Tip.

30

ChipSHOUTER

Page 31: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Triggering EMFI

• TotalPhase Beagle 480• Hardware trigger on USB physical-layer packets!

31

Page 32: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

32

Beagle480 (trigger on USB packet)

Target

ChipWhisperer

USB Switch (hard reset required due to hard fault vectors)

Page 33: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

PhyWhisperer-USB

https://github.com/newaetech/phywhispererusb 33

• Cheapish ($250 USD) triggering device for USB physical-layer packets.

• Works as a sniffer too.

• Open-source HW/SW.

• Needs separate fault injection driver -ChipSHOUTER (EMFI), ChipWhisperer (Voltage glitching), or Mux (Voltage glitching)

Page 34: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

PhyWhisperer-USB

34

• USB 2.0 LS/FS/HS Phy• Can switch power on/off

to target (critical for glitching).

• Interpose with a real (external) USB host.

Stuff that works also:• Sniffing USB packets

(Wireshark as front-end).

Stuff you could do (but I’m way too lazy for):• Generate USB packets.

Page 35: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

• A true history of block chain!

• Me gambling with 0.3 BTC!

• Physical give-aways!

• Attacking bitcoin wallets & stealing funds!

• Stealing authentication credentials!

• Crass commercialization!

• Open-Source Tool Release!

• Fixing your crappy code!

35

Page 36: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

PhyWhisperer on CrowdSupply

36

• Everyone loves OSHW.• Nobody wants to actually build it.• Solution: Search “PhyWhisperer” to see crowd

funding campaign!

Page 37: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

• A true history of block chain!

• Me gambling with 0.3 BTC!

• Physical give-aways!

• Attacking bitcoin wallets & stealing funds!

• Stealing authentication credentials!

• Crass commercialization!

• Open-Source Tool Release!

• Fixing your crappy code!

37

Page 38: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

EMFI Demo

<Hopefully my camera works>

38

Page 39: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

• A true history of block chain!

• Me gambling with 0.3 BTC!

• Physical give-aways!

• Attacking bitcoin wallets & stealing funds!

• Stealing authentication credentials!

• Crass commercialization!

• Open-Source Tool Release!

• Fixing your crappy code!

39

Page 40: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Wait – What About Authentication Tokens?

• Since submitting & preparing this I realized several other interesting targets, and rather than a second talk I give you…

40

BONUSCONTENT

Page 41: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

How do these things work?

41

BONUSCONTENT

Authentication Token Website/App

Private Key

Public Key

Public Key Registration Phase (Once)

Authentication Phase (Many)

Challenge

Signing Operation

Response

Verify

Page 42: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Who’s using these tokens?

42

BONUSCONTENT

Page 43: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Example: Solo Keys Authentication Token

43

BONUSCONTENT

TIP: You can find ECC private keys in memory if you have public key to compare with. If memory layout is unknown, we can register a new service (to get public key from device), perform attack, and figure out if any private keys in our memory dump.

Page 44: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

What about other FIDO2 Keys?

44

BONUSCONTENT

https://fidoalliance.org/certification/authenticator-certification-levels/

e.g., Yubikey 5 should reach this

Page 45: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

• A true history of block chain!

• Me gambling with 0.3 BTC!

• Physical give-aways!

• Attacking bitcoin wallets & stealing funds!

• Stealing authentication credentials!

• Crass commercialization!

• Open-Source Tool Release!

• Fixing your crappy code!

45

Page 46: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

How Concerned Should You Be?

46

Is your device using

USB?

Is sensitive data in same

memory space as USB?

Within 64KB of any USB

data?

YESYESYES

NO NO NO

Page 47: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

How to Fix It?

• Why can you send back 64K of memory? No descriptors are that big!

• Devices have memory protection.• We can armour the sensitive data with invalid memory segments, or “disable”

memory segments when read-out shouldn’t be needed.

• Move memory layout around so we can’t read into sensitive data.• Less useful as another fault might let us corrupt a pointer instead.

• Encrypt data in-place.• Don’t allow a “dumb” dump to figure out this critical data!

47

Page 48: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Trezor Fixes

• The disclosed problem has been fixed in latest firmware patch.

• The disclosed problem did not affect people using passphrases.

https://blog.trezor.io/details-of-security-updates-for-trezor-one-firmware-1-8-0-and-trezor-model-t-firmware-2-1-0-408e59dc012

48

Page 49: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Solo Key Fixes

• The disclosed problem has been fixed in GIT!

49

Page 50: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

• A true history of block chain!

• Me gambling with 0.3 BTC!

• Physical give-aways!

• Attacking bitcoin wallets & stealing funds!

• Stealing authentication credentials!

• Crass commercialization!

• Open-Source Tool Release!

• Fixing your crappy code!

50

Page 51: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Takeaways

• Tamper-resistant enclosures aren’t enough when discussing “near-physical” attacks. Commercially available EMFI tools exist (see -ChipSHOUTER) and can be purchased sometimes...

• If implementing a USB device, validate your response size makes sense to avoid many attacks!

• Testing against EMFI is useful to understand vulnerability – but you can do some testing with simulation/emulation and through code review.

51

Page 52: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

Let’s Do It!

Blog oflynn.com

Twitter @colinoflynn

Email [email protected]

Dal Email [email protected]

Company newae.com52

• I’ve got PhyWhisperer-USB PCBs here for you ☺ Join the CrowdSupply and make the full thing happen!

• See my WOOT’19 paper (linked from oflynn.com) & White Paper!

I’m terrible on response times right now, please don’t take it personally if it takes weeks++ :/

Page 53: MINimum Failure - i.blackhat.com · Wallet.Fail •Vulnerabilities on several Bitcoin Wallets. •For Trezor specifically: •How to copy recovering seed out of a backup stored in

For More, See:

• WOOT 2019 Paper: https://www.usenix.org/conference/woot19/presentation/oflynn

• My blog post: http://colinoflynn.com/2019/03/glitching-trezor-using-emfi-through-the-enclosure/

• PhyWhisperer-USB repo:https://github.com/newaetech/phywhispererusb

53