SlideShare a Scribd company logo
Nick Sullivan 
@grittygrease 
May 16, 2014 
Exploiting Randomness 
Some fun exploits you can do with a compromised random number generator
Who Am I? 
• Cryptography Engineer, Security Researcher 
• Lead the CloudFlare Security Engineering Team 
• Work with Cryptography at scale 
• Builder and Breaker 
2
Randomness 
3
Randomness 
• What is randomness? 
• Why is randomness important? 
• How bad randomness can destroy a computer security system 
4
Randomness 
• Broken random number generator is very problematic 
! 
• This talk demos attacks on: 
• Bitcoin 
• TLS/SSL 
5
Randomness 
• Random number generators can be compromised in multiple ways 
! 
• Explicit subversion 
• Algorithmic weakness 
• Poor seeding 
! 
• All three are exploitable 
6
The Internet is broken 
7
The Internet is broken 
• A failure of trust at scale 
• Slow adoption by community of new standards 
• DNSSEC 
• Perfect Forward Secrecy 
• Fundamental parts of it are broken 
• Revocation — as shown by Heartbleed vulnerability 
8
A trying year 
• Events since June 2013 exposed fragility 
• Threats moved from theoretical to concrete 
• Opinions of the “paranoid” are now mainstream 
9
Leaked documents 
• Purported attempts to subvert public standards and open source projects 
• Subversion of random number generation 
• I can talk about this since I was never involved 
10
Dual_EC_DRBG 
11
Dual_EC_DRBG 
• It was reported that RSA took 10 million to make 
Dual_EC_DRBG default in BSAFE in 2004 
• Removed as default in 2013 
12
Dual_EC_DRBG 
• Clumsy, slow random number generator based on elliptic curves 
• Came with two “random” starting points 
• Missed opportunity(?) if they are random 
• Starting points can be chosen such that creator has a back door 
• Patented by Vanstone and Brown (2005) 
• 32 bytes of data reveal entire stream 
13
Dual_EC_DRBG 
• Internal state is entirely dependent on the seed 
14
Dual_EC_DRBG 
• TLS client hello only reveals 28 bytes of random 
• RSA implemented non-standard “extended random” TLS extension 
• Reveals the full 32 bytes of consecutive data required 
15
Dual_EC_DRBG 
• “On the Practical Exploitability of Dual EC in TLS Implementations” - 2014 
• Lange, Bernstein, Green, et al. 
• Looked into OpenSSL-FIPS, SChannel, BSAFE, used trojaned points 
! 
• Findings 
• TLS for each are fingerprintable 
• TLS session key in seconds to hours of computation — passively 
16
Dual_EC_DRBG - Takeaways 
• Many protocols include random values (nonces, IVs, session ids, etc.) 
• Internal state can be recovered with this data 
• All future random can be derived from internal state 
17
Intel RDRAND 
18
Intel RDRAND 
• IvyBridge and later random number generator — in hardware 
• Designed to be fast 
• Has an AES-based “whitening” step at the end 
19
Intel RDRAND 
20
Intel RDRAND 
• Exploitability: it’s a hardware instruction 
• Virtualized environments - override from hypervisor 
• Microcode updates 
! 
• Verifiability 
• Designers have not looked at production chips in Haswell 
• Is there a backdoor in silicon? Hard to tell. 
21
Intel RDRAND 
• FreeBSD and Linux patched to make RDRAND sole source of entropy 
• Eventually patches were blocked or reverted 
• Linux now mixes RDRAND into /dev/random 
! 
• What motivated these patches? 
22
Intel RDRAND - takeaways 
• Randomness can come from hardware 
• Should be mixed with other sources 
• Looking at randomness does not reveal backdoors 
23
A bit about entropy 
24
A bit about entropy 
• Why is RDRAND dangerous on its own, but ok to mix? 
! 
• Statistical randomness is not enough 
• Cryptographic randomness needs 
• To be unpredictable 
• To have high entropy 
25
A bit about entropy 
• Entropy is the amount of information contained in a sequence of numbers 
• If you know the sequence, it is predictable 
! 
• The digits of pi are statistically random, but are predictable 
• The entropy is equivalent to the definition: 
“ratio of circumference to diameter of a circle” 
• This sentence only needs a few bytes to express 
26
A bit about entropy 
• Entropy is in the eyes of the beholder 
• Known information takes away from the entropy 
• Digits of pi have high entropy to someone who doesn’t know math 
! 
• The NIST random beacon is not cryptographic randomness 
• Generated with high entropy process, but disclosed to the world 
27
A bit about entropy 
• Encrypted the digits of pi with a 128 bit AES key 
• Tell the world that’s what it is 
! 
• The entropy to you is low 
• The entropy to the world is 128 bit 
28
A bit about entropy 
• Same with Dual_EC_DRBG 
• Say P = nQ 
• The relationship between P & Q can be computed by solving ECDLP 
• That takes ~2^128 computations 
• The entropy to the world is 128 bits 
• The entropy to whoever knows n (the creator) is almost zero given 32 
consecutive bytes 
29
A bit about entropy 
• Independent entropy is additive 
• RDRAND is ok to mix in, it can only increase randomness 
30
The Digital Signature Algorithm (DSA) 
31
The Digital Signature Algorithm (DSA) 
• Public Key cryptography primitive proposed in 1991 
• Allows the owner of a private key to sign hash of a message 
• The public key is used to verify the signature 
32
The Digital Signature Algorithm (DSA) 
• Where is it used? Everywhere. 
• What kind of key is your ssh key? 
• ECDSA: elliptic curve variant used in TLS, bitcoin 
33
The Digital Signature Algorithm (DSA) 
• Core complaint: DSA and ECDSA require cryptographic randomness 
• Repeated signature with same random value reveal the private key 
34
The Digital Signature Algorithm (DSA) 
• Signature 
• Pick a random k 
• Convolute k with private key and hash of message 
• Publish R, S 
! 
• Solve DLP on R -> k 
35
The Digital Signature Algorithm (DSA) 
• Any known k 
• Extract private key 
• Any repeated k with same private key 
• Extract k 
36
The Digital Signature Algorithm (DSA) 
• The Math 
37
The Digital Signature Algorithm (DSA) 
• The Math 
38
The Digital Signature Algorithm (DSA) 
• Breaking DSA 
39
Bitcoin 
40
Bitcoin 
• Fundamental security based on ECDSA 
• Public key hash is your Bitcoin address 
• Private key allows you to spend 
• ECDSA signature proves transaction 
41
Bitcoin 
• OP_CHECKSIG 
• Verify that a payment was made 
42
Bitcoin 
• Two transactions by same Bitcoin address with same random value k 
! 
• Signature includes S, R 
• R = kG, where G is base point 
• If R1 = R1, most likely the same k was used 
43
Bitcoin 
• Demo 
• /fun - 
hash1="270666214c4a9654e2b0c40cbe6e57331ab2d8034f8c648944d5d3c7550b46dc" - 
sig1="4830450221009ac20335eb38768d2052be1dbbc3c8f6178407458e51e6b4ad22f1d 
91758895b02201b0d10a717ffccbfe5483bb7aa1cdcdc2a4e8775c706aaeddbcbfd55df190 
dd5012103ffffc29d98bf4eec11e6948387bdf5928848dca7b83bfde8e0e627e66c706576" - 
hash2="9bc17698be66f12460b7d7f87e47e1bbc03203194d0cf539ca9b862b23742b0a" - 
sig2="4830450221009ac20335eb38768d2052be1dbbc3c8f6178407458e51e6b4ad22f1d 
91758895b0220507b798addf5097c11fb4ed40518b2c3e468feb3d09a1fea837cf9d16ae2 
5ef6012103ffffc29d98bf4eec11e6948387bdf5928848dca7b83bfde8e0e627e66c706576" 
44
Other DSA risks 
• VPN signatures 
• IPSec uses DSA, ECDSA 
• OpenVPN 
• SSH keys 
• Secure boot chain 
• low entropy boot environments 
• Codesigning keys 
45
Symptoms of DSA break 
• Look at the R value 
• Repeating R means your key is 
compromised 
46
RSA 
47
RSA 
• Public Key Cryptosystem 
• Basis of the Public Key Infrastructure 
• Security is based on strength of factoring large numbers 
! 
• RSA modulus N has two factors P & Q 
• RSA key pairs created by randomly generating P & Q 
48
RSA 
• Taiwanese government id: each person has a unique RSA key 
49
RSA 
• Factoring P*Q is hard 
• Factoring P*Q and P*R is easy: Chinese remainder theorem 
• You can also find the GCD of a large number of numbers 
! 
• Factoring RSA keys from certified smart cards: Coppersmith in the wild - 2013 
• This is exactly what Bernstein, Heninger, Lange did 
50
RSA 
• They found that some even had recognizable patterns 
51
RSA 
• Result of bad entropy initialization, bad RNG 
• No Demo, https://factorable.net covers it 
52
RSA 
• Need to attack before keys are created 
• Bootloading, early execution vulnerable to weak PRNG 
• TrueCrypt? GnuPG? Probably. 
• Rely on system to generate RSA keys 
• Routers and embedded devices - ephemeral RSA keys 
53
RSA 
• What are the symptoms? 
• No symptoms, totally passive 
• Where can you harvest public keys? 
• Scan the internet 
• PGP lists - keybase.io? 
54
TLS 
55
TLS 
• The crown jewel of Internet encryption is SSL/TLS 
• Breaking this removes privacy on the internet 
• I will demonstrate one attack and point out two others 
56
Handshake 
• Breakdown of RSA handshake 
! 
• Random from client 
• Decryption from server 
57
Handshake 
• Breakdown of DHE handshake 
! 
• Random from Client 
• Random from Server 
58
DH on the wire 
• Client sends aG 
• Server sends bG 
• Pre-master secret is abG 
59
Perfect Secrecy 
• RSA is vulnerable to client randomness bugs — session key leak 
• ECDSA is vulnerable to server randomness bugs — private key leak 
• DH is vulnerable to both client and server randomness bugs 
60
TLS 
• Demo 
• node.js server with a modified OpenSSL binding for the RNG 
• Do a handshake 
• Measure it, steal DH private key, decrypt stream 
61
Vectors of attack 
62
Vectors of attack 
63 
Application 
Userland 
CSPRNG 
sharedlib 
/dev/random 
Kernel timing 
Hypervisor RDRAND
How to exploit more generally 
• Override RDRAND in hypervisor 
• Other protocols: OpenVPN, IPSec 
• Where to find randomness for context: nonces, IVs 
• Trojan the OS image — /dev/random or system openssl 
• Extracting RNG state through remote memory disclosure: heartbleed 
64
More examples from history 
• RSA 
• Debian RNG 
• ECDSA 
• Sony Playstation 2 
• Android Wallet 
• Examples: iOS 7.0 bootloader RNG — change BIOS 
65
More targets 
• Other things that depend on good RNG 
! 
• Session cookies 
• Kaminsky’s DNS poisoning attack mitigation 
• Suite B - ECDSA Certificate Authorities 
66
Conclusion 
• Randomness is important 
• Subverting PRNG 
• Can be done in different layers 
• Very hard to detect 
• Exploit bugs in PRNG 
• Repeated random breaks DSA 
67
Nick Sullivan 
@grittygrease 
May 16, 2014 
Exploiting Randomness 
Some fun exploits you can do with a compromised random number generator

More Related Content

PDF
Sullivan white boxcrypto-baythreat-2013
PDF
Sullivan red october-oscon-2014
PDF
Sullivan handshake proxying-ieee-sp_2014
PDF
Running Secure Server Software on Insecure Hardware Without Parachute
PDF
Sullivan heartbleed-defcon22 2014
PPTX
Botconf ppt
PDF
Virus Bulletin 2012
PDF
Heartache and Heartbleed - 31c3
Sullivan white boxcrypto-baythreat-2013
Sullivan red october-oscon-2014
Sullivan handshake proxying-ieee-sp_2014
Running Secure Server Software on Insecure Hardware Without Parachute
Sullivan heartbleed-defcon22 2014
Botconf ppt
Virus Bulletin 2012
Heartache and Heartbleed - 31c3

What's hot (20)

PDF
An analysis of TLS handshake proxying
PDF
Bringing Elliptic Curve Cryptography into the Mainstream
PDF
CFSSL 1.1: The Evolution of a PKI toolkit - DEF CON 23
PDF
What's New in Go Crypto - Gotham Go
PDF
Overview of SSL: choose the option that's right for you
PDF
DEVNET-1007 Network Infrastructure as Code with Chef and Cisco
PDF
Security with VA Smalltalk
PDF
y3dips hacking priv8 network
PPTX
The 3 Models in the NGINX Microservices Reference Architecture
PPTX
TLS 1.3 and Other New Features in NGINX Plus R17 and NGINX Open Source
PDF
TLS 1.3 and Other New Features in NGINX Plus R17 and NGINX Open Source EMEA
PPTX
MRA AMA Part 7: The Circuit Breaker Pattern
PDF
Monitoring Highly Dynamic and Distributed Systems with NGINX Amplify
PPTX
Owasp crypto tools and projects
PDF
Crikeycon 2019 Velociraptor Workshop
PDF
An Introduction to DANE - Securing TLS using DNSSEC
PDF
Bridges and Tunnels: A Drive Through OpenStack Networking
PPTX
Running a Robust DNS Infrastructure with CloudFlare Virtual DNS
PPTX
Reinventing anon email
PDF
CNIT 128 3. Attacking iOS Applications (Part 1)
An analysis of TLS handshake proxying
Bringing Elliptic Curve Cryptography into the Mainstream
CFSSL 1.1: The Evolution of a PKI toolkit - DEF CON 23
What's New in Go Crypto - Gotham Go
Overview of SSL: choose the option that's right for you
DEVNET-1007 Network Infrastructure as Code with Chef and Cisco
Security with VA Smalltalk
y3dips hacking priv8 network
The 3 Models in the NGINX Microservices Reference Architecture
TLS 1.3 and Other New Features in NGINX Plus R17 and NGINX Open Source
TLS 1.3 and Other New Features in NGINX Plus R17 and NGINX Open Source EMEA
MRA AMA Part 7: The Circuit Breaker Pattern
Monitoring Highly Dynamic and Distributed Systems with NGINX Amplify
Owasp crypto tools and projects
Crikeycon 2019 Velociraptor Workshop
An Introduction to DANE - Securing TLS using DNSSEC
Bridges and Tunnels: A Drive Through OpenStack Networking
Running a Robust DNS Infrastructure with CloudFlare Virtual DNS
Reinventing anon email
CNIT 128 3. Attacking iOS Applications (Part 1)
Ad

Viewers also liked (18)

PDF
Go Containers
PDF
Secure 2013 Poland
PDF
CloudFlare - The Heartbleed Bug - Webinar
KEY
SortaSQL
PPTX
Managing Traffic Spikes This Holiday Season
PDF
WordPress London Meetup January 2012
PDF
How to Meet FFIEC Regulations and Protect Your Bank from Cyber Attacks
PDF
A Channel Compendium
PDF
Go Profiling - John Graham-Cumming
PDF
Hardening Microservices Security: Building a Layered Defense Strategy
PPTX
Latest Trends in Web Application Security
PPTX
Surviving A DDoS Attack: Securing CDN Traffic at CloudFlare
PDF
Wireless Sensor Networks: Nothing is Out of Reach
PPTX
Where Are All The ICS Attacks?
PDF
Gary Leatherman - A Holistic Approach for Reimagining Cyber Defense
PDF
Compromising Industrial Facilities From 40 Miles Away
PDF
Please, Come and Hack my SCADA System!
PDF
What to do when pseudo- is not good enough
Go Containers
Secure 2013 Poland
CloudFlare - The Heartbleed Bug - Webinar
SortaSQL
Managing Traffic Spikes This Holiday Season
WordPress London Meetup January 2012
How to Meet FFIEC Regulations and Protect Your Bank from Cyber Attacks
A Channel Compendium
Go Profiling - John Graham-Cumming
Hardening Microservices Security: Building a Layered Defense Strategy
Latest Trends in Web Application Security
Surviving A DDoS Attack: Securing CDN Traffic at CloudFlare
Wireless Sensor Networks: Nothing is Out of Reach
Where Are All The ICS Attacks?
Gary Leatherman - A Holistic Approach for Reimagining Cyber Defense
Compromising Industrial Facilities From 40 Miles Away
Please, Come and Hack my SCADA System!
What to do when pseudo- is not good enough
Ad

Similar to Sullivan randomness-infiltrate 2014 (20)

PDF
Crypto 101: Encryption, Codebreaking, SSL and Bitcoin
PPTX
Secure coding for developers
PDF
Module: drand - the Distributed Randomness Beacon
PDF
Cryptography
PDF
When Crypto Attacks! (Yahoo 2009)
PDF
Crypto Strikes Back! (Google 2009)
PDF
Asymmetric Cryptography
PDF
Encryption Deep Dive
PDF
Go paranoid
PDF
hashdays 2011: Jean-Philippe Aumasson - Cryptanalysis vs. Reality
PDF
Common crypto attacks and secure implementations
PDF
The CDO Agenda - Data Security and Encryption
PPT
Chapter 15 - Security
PDF
PDF
PDF
PDF
CNIT 123 12: Cryptography
PDF
Linux randomnumbergenerator
PDF
Twenty years of attacks on the rsa cryptosystem
PDF
CNIT 141: 2. Randomness
Crypto 101: Encryption, Codebreaking, SSL and Bitcoin
Secure coding for developers
Module: drand - the Distributed Randomness Beacon
Cryptography
When Crypto Attacks! (Yahoo 2009)
Crypto Strikes Back! (Google 2009)
Asymmetric Cryptography
Encryption Deep Dive
Go paranoid
hashdays 2011: Jean-Philippe Aumasson - Cryptanalysis vs. Reality
Common crypto attacks and secure implementations
The CDO Agenda - Data Security and Encryption
Chapter 15 - Security
CNIT 123 12: Cryptography
Linux randomnumbergenerator
Twenty years of attacks on the rsa cryptosystem
CNIT 141: 2. Randomness

More from Cloudflare (20)

PDF
Succeeding with Secure Access Service Edge (SASE)
PPTX
Close your security gaps and get 100% of your traffic protected with Cloudflare
PPTX
Why you should replace your d do s hardware appliance
PPTX
Don't Let Bots Ruin Your Holiday Business - Snackable Webinar
PPTX
Why Zero Trust Architecture Will Become the New Normal in 2021
PPTX
HARTMANN and Cloudflare Learn how healthcare providers can build resilient in...
PPTX
Zero trust for everybody: 3 ways to get there fast
PPTX
LendingTree and Cloudflare: Ensuring zero trade-off between security and cust...
PPTX
Network Transformation: What it is, and how it’s helping companies stay secur...
PPTX
Scaling service provider business with DDoS-mitigation-as-a-service
PPTX
Application layer attack trends through the lens of Cloudflare data
PPTX
Recent DDoS attack trends, and how you should respond
PPTX
Cybersecurity 2020 threat landscape and its implications (AMER)
PPTX
Strengthening security posture for modern-age SaaS providers
PPTX
Kentik and Cloudflare Partner to Mitigate Advanced DDoS Attacks
PDF
Stopping DDoS Attacks in North America
PPTX
It’s 9AM... Do you know what’s happening on your network?
PPTX
Cyber security fundamentals (simplified chinese)
PPTX
Bring speed and security to the intranet with cloudflare for teams
PPTX
Accelerate your digital transformation
Succeeding with Secure Access Service Edge (SASE)
Close your security gaps and get 100% of your traffic protected with Cloudflare
Why you should replace your d do s hardware appliance
Don't Let Bots Ruin Your Holiday Business - Snackable Webinar
Why Zero Trust Architecture Will Become the New Normal in 2021
HARTMANN and Cloudflare Learn how healthcare providers can build resilient in...
Zero trust for everybody: 3 ways to get there fast
LendingTree and Cloudflare: Ensuring zero trade-off between security and cust...
Network Transformation: What it is, and how it’s helping companies stay secur...
Scaling service provider business with DDoS-mitigation-as-a-service
Application layer attack trends through the lens of Cloudflare data
Recent DDoS attack trends, and how you should respond
Cybersecurity 2020 threat landscape and its implications (AMER)
Strengthening security posture for modern-age SaaS providers
Kentik and Cloudflare Partner to Mitigate Advanced DDoS Attacks
Stopping DDoS Attacks in North America
It’s 9AM... Do you know what’s happening on your network?
Cyber security fundamentals (simplified chinese)
Bring speed and security to the intranet with cloudflare for teams
Accelerate your digital transformation

Recently uploaded (20)

PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PPTX
Digital Literacy And Online Safety on internet
PPT
tcp ip networks nd ip layering assotred slides
PPTX
innovation process that make everything different.pptx
PDF
Sims 4 Historia para lo sims 4 para jugar
PDF
Testing WebRTC applications at scale.pdf
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PDF
The Internet -By the Numbers, Sri Lanka Edition
PPTX
Internet___Basics___Styled_ presentation
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PPTX
Introduction to Information and Communication Technology
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PPTX
QR Codes Qr codecodecodecodecocodedecodecode
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PDF
Triggering QUIC, presented by Geoff Huston at IETF 123
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
Slides PDF The World Game (s) Eco Economic Epochs.pdf
Job_Card_System_Styled_lorem_ipsum_.pptx
Digital Literacy And Online Safety on internet
tcp ip networks nd ip layering assotred slides
innovation process that make everything different.pptx
Sims 4 Historia para lo sims 4 para jugar
Testing WebRTC applications at scale.pdf
WebRTC in SignalWire - troubleshooting media negotiation
Cloud-Scale Log Monitoring _ Datadog.pdf
The Internet -By the Numbers, Sri Lanka Edition
Internet___Basics___Styled_ presentation
INTERNET------BASICS-------UPDATED PPT PRESENTATION
Introduction to Information and Communication Technology
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
QR Codes Qr codecodecodecodecocodedecodecode
Paper PDF World Game (s) Great Redesign.pdf
Introuction about WHO-FIC in ICD-10.pptx
Triggering QUIC, presented by Geoff Huston at IETF 123
Tenda Login Guide: Access Your Router in 5 Easy Steps
RPKI Status Update, presented by Makito Lay at IDNOG 10

Sullivan randomness-infiltrate 2014

  • 1. Nick Sullivan @grittygrease May 16, 2014 Exploiting Randomness Some fun exploits you can do with a compromised random number generator
  • 2. Who Am I? • Cryptography Engineer, Security Researcher • Lead the CloudFlare Security Engineering Team • Work with Cryptography at scale • Builder and Breaker 2
  • 4. Randomness • What is randomness? • Why is randomness important? • How bad randomness can destroy a computer security system 4
  • 5. Randomness • Broken random number generator is very problematic ! • This talk demos attacks on: • Bitcoin • TLS/SSL 5
  • 6. Randomness • Random number generators can be compromised in multiple ways ! • Explicit subversion • Algorithmic weakness • Poor seeding ! • All three are exploitable 6
  • 7. The Internet is broken 7
  • 8. The Internet is broken • A failure of trust at scale • Slow adoption by community of new standards • DNSSEC • Perfect Forward Secrecy • Fundamental parts of it are broken • Revocation — as shown by Heartbleed vulnerability 8
  • 9. A trying year • Events since June 2013 exposed fragility • Threats moved from theoretical to concrete • Opinions of the “paranoid” are now mainstream 9
  • 10. Leaked documents • Purported attempts to subvert public standards and open source projects • Subversion of random number generation • I can talk about this since I was never involved 10
  • 12. Dual_EC_DRBG • It was reported that RSA took 10 million to make Dual_EC_DRBG default in BSAFE in 2004 • Removed as default in 2013 12
  • 13. Dual_EC_DRBG • Clumsy, slow random number generator based on elliptic curves • Came with two “random” starting points • Missed opportunity(?) if they are random • Starting points can be chosen such that creator has a back door • Patented by Vanstone and Brown (2005) • 32 bytes of data reveal entire stream 13
  • 14. Dual_EC_DRBG • Internal state is entirely dependent on the seed 14
  • 15. Dual_EC_DRBG • TLS client hello only reveals 28 bytes of random • RSA implemented non-standard “extended random” TLS extension • Reveals the full 32 bytes of consecutive data required 15
  • 16. Dual_EC_DRBG • “On the Practical Exploitability of Dual EC in TLS Implementations” - 2014 • Lange, Bernstein, Green, et al. • Looked into OpenSSL-FIPS, SChannel, BSAFE, used trojaned points ! • Findings • TLS for each are fingerprintable • TLS session key in seconds to hours of computation — passively 16
  • 17. Dual_EC_DRBG - Takeaways • Many protocols include random values (nonces, IVs, session ids, etc.) • Internal state can be recovered with this data • All future random can be derived from internal state 17
  • 19. Intel RDRAND • IvyBridge and later random number generator — in hardware • Designed to be fast • Has an AES-based “whitening” step at the end 19
  • 21. Intel RDRAND • Exploitability: it’s a hardware instruction • Virtualized environments - override from hypervisor • Microcode updates ! • Verifiability • Designers have not looked at production chips in Haswell • Is there a backdoor in silicon? Hard to tell. 21
  • 22. Intel RDRAND • FreeBSD and Linux patched to make RDRAND sole source of entropy • Eventually patches were blocked or reverted • Linux now mixes RDRAND into /dev/random ! • What motivated these patches? 22
  • 23. Intel RDRAND - takeaways • Randomness can come from hardware • Should be mixed with other sources • Looking at randomness does not reveal backdoors 23
  • 24. A bit about entropy 24
  • 25. A bit about entropy • Why is RDRAND dangerous on its own, but ok to mix? ! • Statistical randomness is not enough • Cryptographic randomness needs • To be unpredictable • To have high entropy 25
  • 26. A bit about entropy • Entropy is the amount of information contained in a sequence of numbers • If you know the sequence, it is predictable ! • The digits of pi are statistically random, but are predictable • The entropy is equivalent to the definition: “ratio of circumference to diameter of a circle” • This sentence only needs a few bytes to express 26
  • 27. A bit about entropy • Entropy is in the eyes of the beholder • Known information takes away from the entropy • Digits of pi have high entropy to someone who doesn’t know math ! • The NIST random beacon is not cryptographic randomness • Generated with high entropy process, but disclosed to the world 27
  • 28. A bit about entropy • Encrypted the digits of pi with a 128 bit AES key • Tell the world that’s what it is ! • The entropy to you is low • The entropy to the world is 128 bit 28
  • 29. A bit about entropy • Same with Dual_EC_DRBG • Say P = nQ • The relationship between P & Q can be computed by solving ECDLP • That takes ~2^128 computations • The entropy to the world is 128 bits • The entropy to whoever knows n (the creator) is almost zero given 32 consecutive bytes 29
  • 30. A bit about entropy • Independent entropy is additive • RDRAND is ok to mix in, it can only increase randomness 30
  • 31. The Digital Signature Algorithm (DSA) 31
  • 32. The Digital Signature Algorithm (DSA) • Public Key cryptography primitive proposed in 1991 • Allows the owner of a private key to sign hash of a message • The public key is used to verify the signature 32
  • 33. The Digital Signature Algorithm (DSA) • Where is it used? Everywhere. • What kind of key is your ssh key? • ECDSA: elliptic curve variant used in TLS, bitcoin 33
  • 34. The Digital Signature Algorithm (DSA) • Core complaint: DSA and ECDSA require cryptographic randomness • Repeated signature with same random value reveal the private key 34
  • 35. The Digital Signature Algorithm (DSA) • Signature • Pick a random k • Convolute k with private key and hash of message • Publish R, S ! • Solve DLP on R -> k 35
  • 36. The Digital Signature Algorithm (DSA) • Any known k • Extract private key • Any repeated k with same private key • Extract k 36
  • 37. The Digital Signature Algorithm (DSA) • The Math 37
  • 38. The Digital Signature Algorithm (DSA) • The Math 38
  • 39. The Digital Signature Algorithm (DSA) • Breaking DSA 39
  • 41. Bitcoin • Fundamental security based on ECDSA • Public key hash is your Bitcoin address • Private key allows you to spend • ECDSA signature proves transaction 41
  • 42. Bitcoin • OP_CHECKSIG • Verify that a payment was made 42
  • 43. Bitcoin • Two transactions by same Bitcoin address with same random value k ! • Signature includes S, R • R = kG, where G is base point • If R1 = R1, most likely the same k was used 43
  • 44. Bitcoin • Demo • /fun - hash1="270666214c4a9654e2b0c40cbe6e57331ab2d8034f8c648944d5d3c7550b46dc" - sig1="4830450221009ac20335eb38768d2052be1dbbc3c8f6178407458e51e6b4ad22f1d 91758895b02201b0d10a717ffccbfe5483bb7aa1cdcdc2a4e8775c706aaeddbcbfd55df190 dd5012103ffffc29d98bf4eec11e6948387bdf5928848dca7b83bfde8e0e627e66c706576" - hash2="9bc17698be66f12460b7d7f87e47e1bbc03203194d0cf539ca9b862b23742b0a" - sig2="4830450221009ac20335eb38768d2052be1dbbc3c8f6178407458e51e6b4ad22f1d 91758895b0220507b798addf5097c11fb4ed40518b2c3e468feb3d09a1fea837cf9d16ae2 5ef6012103ffffc29d98bf4eec11e6948387bdf5928848dca7b83bfde8e0e627e66c706576" 44
  • 45. Other DSA risks • VPN signatures • IPSec uses DSA, ECDSA • OpenVPN • SSH keys • Secure boot chain • low entropy boot environments • Codesigning keys 45
  • 46. Symptoms of DSA break • Look at the R value • Repeating R means your key is compromised 46
  • 48. RSA • Public Key Cryptosystem • Basis of the Public Key Infrastructure • Security is based on strength of factoring large numbers ! • RSA modulus N has two factors P & Q • RSA key pairs created by randomly generating P & Q 48
  • 49. RSA • Taiwanese government id: each person has a unique RSA key 49
  • 50. RSA • Factoring P*Q is hard • Factoring P*Q and P*R is easy: Chinese remainder theorem • You can also find the GCD of a large number of numbers ! • Factoring RSA keys from certified smart cards: Coppersmith in the wild - 2013 • This is exactly what Bernstein, Heninger, Lange did 50
  • 51. RSA • They found that some even had recognizable patterns 51
  • 52. RSA • Result of bad entropy initialization, bad RNG • No Demo, https://factorable.net covers it 52
  • 53. RSA • Need to attack before keys are created • Bootloading, early execution vulnerable to weak PRNG • TrueCrypt? GnuPG? Probably. • Rely on system to generate RSA keys • Routers and embedded devices - ephemeral RSA keys 53
  • 54. RSA • What are the symptoms? • No symptoms, totally passive • Where can you harvest public keys? • Scan the internet • PGP lists - keybase.io? 54
  • 56. TLS • The crown jewel of Internet encryption is SSL/TLS • Breaking this removes privacy on the internet • I will demonstrate one attack and point out two others 56
  • 57. Handshake • Breakdown of RSA handshake ! • Random from client • Decryption from server 57
  • 58. Handshake • Breakdown of DHE handshake ! • Random from Client • Random from Server 58
  • 59. DH on the wire • Client sends aG • Server sends bG • Pre-master secret is abG 59
  • 60. Perfect Secrecy • RSA is vulnerable to client randomness bugs — session key leak • ECDSA is vulnerable to server randomness bugs — private key leak • DH is vulnerable to both client and server randomness bugs 60
  • 61. TLS • Demo • node.js server with a modified OpenSSL binding for the RNG • Do a handshake • Measure it, steal DH private key, decrypt stream 61
  • 63. Vectors of attack 63 Application Userland CSPRNG sharedlib /dev/random Kernel timing Hypervisor RDRAND
  • 64. How to exploit more generally • Override RDRAND in hypervisor • Other protocols: OpenVPN, IPSec • Where to find randomness for context: nonces, IVs • Trojan the OS image — /dev/random or system openssl • Extracting RNG state through remote memory disclosure: heartbleed 64
  • 65. More examples from history • RSA • Debian RNG • ECDSA • Sony Playstation 2 • Android Wallet • Examples: iOS 7.0 bootloader RNG — change BIOS 65
  • 66. More targets • Other things that depend on good RNG ! • Session cookies • Kaminsky’s DNS poisoning attack mitigation • Suite B - ECDSA Certificate Authorities 66
  • 67. Conclusion • Randomness is important • Subverting PRNG • Can be done in different layers • Very hard to detect • Exploit bugs in PRNG • Repeated random breaks DSA 67
  • 68. Nick Sullivan @grittygrease May 16, 2014 Exploiting Randomness Some fun exploits you can do with a compromised random number generator