56
Public Key Infrastructure Chester Rebeiro IIT Madras

Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Public Key Infrastructure

ChesterRebeiroIITMadras

Page 2: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

•  KeyEstablishment:“AliceandBobwanttouseablockcipherforencryption.Howdotheyagreeuponthesecretkey”

2

AliceandBobagreeuponaprimepandageneratorg.Thisispublicinformation

chooseasecretacomputeA=gamodp

chooseasecretbcomputeB=gbmodp

B A

ComputeK=Bamodp ComputeK=Abmodp

Abmodp=(ga)bmodp=(gb)amodp=Bamodp

Recollect Diffie-Hellman Key Exchange

Page 3: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Man in the Middle Attack

3

Alicesendshispublickey

Alicedecryptswithherprivatekey

Bobencrypts

withSally’spu

blickey

ManinthemiddleInterceptsmessages

Sallysendsherpublickey

Sallydecryptswithherprivatekeyandre-encryptsWithAlice’spublickey

Page 4: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Man in the Middle Attack

4

Alicesendshispublickey

Alicedecryptswithherprivatekey

Sallyencrypt

s

withMallory’

spublickey

ManinthemiddleInterceptsmessages

Sallysendsherpublickey

Sallydecryptswithherprivatekeyandre-encryptsWithAlice’spublickey

FundamentalProblem:WhoisAlice?Bob has no way to tell whether the public key he receivedbelongstoAliceornot.

Page 5: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

5

chooseasecretacomputeA=gamodp

chooseasecretbcomputeB=gbmodp

DigitallycertificatePublickeyofBob(B)

ComputeK=Bamodp ComputeK=Abmodp

Certifying Authority

DigitallycertificatePublickeyofAlice(A)

Page 6: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

X.509 Digital Certificates

Contains•  SerialNumber•  Issueràthecertifyingauthoritydetails•  Subjectàinformationabouttheowner(whoown’sthepublickeyforexampleAlice)•  PublicKeyàAlice’spublickey•  Validity•  SignatureàThesignatureofthecertificatesignedbythecertifyingauthority

6

Page 7: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

7

A more practical Perspective

Page 8: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

8

A more practical Perspective

VerifythesubjectEnsurethatthepersonapplyingforthecertificateeitherownsorrepresentstheidentityinthesubjectfield.

2,VerifyIdentityofAlice

Page 9: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

9

A more practical Perspective

SigningdigitalcertificatesCAgeneratesadigitalsignatureforthecertificateusingitsprivatekey.Oncethesignatureisapplied,thecertificatecannotbemodified.SignaturescanbeverifiedbyanyonewiththeCA’spublickey.

2,VerifyIdentityofAlice3.DigitallySign

Page 10: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

10

4.Alice’scertificateSignedbyCA

A more practical Perspective

Alicecanadvertisethecertificateonherwebsite

2,VerifyIdentityofAlice3.DigitallySign

Page 11: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

11

chooseasecretacomputeA=gamodp chooseasecretb

computeB=gbmodp

Alice’scertificateSignedbyCA

ComputeK=Bamodp ComputeK=Abmodp

A more practical Perspective

Bob’scertificateSignedbyCA

Alice’scertificateBob’scertificate

Page 12: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Fetching certificates with openssl

12

Hostname:portheader

Certificate1

header

Certificate2

--BEGINCERTIFICATE----ENDCERTIFICATE--

Page 13: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Fetching certificates with openssl

13

Hostname:port

Cutandpasteinafilepaypal.pem(PEM:privacyenhancedmail)Toviewtextequivalentofthis,useopenssl x509 –in paypal.pem –text -noout

Page 14: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Example of X.509 Certificate (1st Part)

TheCA’sidentity(Symantec)

Theownerofthecertificate(paypal)

Page 15: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Example of X.509 Certificate (2nd Part)

Publickey

CA’ssignature

Page 16: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Who Certifies the CA?

16

TherearemanyCAsintherealworld,andtheyareorganizedinahierarchicalstructure.

Page 17: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Root CAs and Self-Signed Certificate

•  A root CA’s public key is also stored in an X.509 certificate. It is self-signed.

•  Self-signed:theentriesfortheissuerandthesubjectareidentical.•  Howcantheybetrusted?

•  PublickeysofrootCAsarepre-installedintheOS,browsersandothersoftware

Same

Page 18: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Root CAs in Mac OS

18

Page 19: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Intermediate CAs and Chain of Trust

Paypal’scertificate

IntermediateCA’scertificate

AisusedtoverifyB

B

A

SomethingelseisneedtoverifyA(certificatefromanotherintermediateCAorrootCA)

Page 20: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Fetching certificates with openssl

20

Hostname:portheader

Certificate1

header

Certificate2

--BEGINCERTIFICATE----ENDCERTIFICATE--

Page 21: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

21

Page 22: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

22

Page 23: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Manually Verifying a Certificate Chain

•  Paypal.pem:SavePaypal’scertificatetoafilecalled•  Symatec-g3.pem:Savecertificatefrom“SymantecClass3EVSSLCA–G3”•  VeriSign-G5.pem:SavetheVeriSign-G5’scertificatefromthebrowser

RootCA’scertificate

Chainofcertificates

Page 24: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

The Entire Process

24

1.SetuptheCA

CA

Page 25: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

25

1.SetuptheCA

CA’sselfsignedcertificate

CA’spublic-privatekey(passwordprotected)

Page 26: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

26

1.SetuptheCA

modelCA’scertificate

Selfsigned

Page 27: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

The Entire Process

27

1.SetuptheCA

1.GenerateKeys

CA

user

Page 28: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

28

1.UserGenerateKeys

Page 29: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

29

1.UserGenerateKeys

n=pxqn

Publickey(A)

Privatekey(a)

p

q

ap

aq

q-1

Page 30: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

The Entire Process

30

1.SetuptheCA

1.GenerateKeys

CA

user

2.GenerateCSR(certisigningreq)

Page 31: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

31

2.GenerateCSR(certisigningreq)

Page 32: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

32

2.GenerateCSR(certisigningreq)

Signedwiththebank’sprivatekey(selfsigned)

Page 33: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

The Entire Process

33

1.SetuptheCA

1.GenerateKeys

CA

user

2.GenerateCSR(certisigningreq) 2.CreateCertificateSendcsrfile

Page 34: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

34

2.CreateCertificate

Page 35: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

The Entire Process

35

1.SetuptheCA

1.GenerateKeys

CA

user

2.GenerateCSR(certisigningreq) 2.CreateCertificate

Sendcertificate

3.Deploy(httpsserver)

Page 36: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

36

3.Deploy

Page 37: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

The Entire Process

37

1.SetuptheCA

1.GenerateKeys

CA

user

2.GenerateCSR(certisigningreq) 2.CreateCertificate

3.Deploy(httpsserver)

client

Page 38: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

38

clientAclientfailstoconnectbecauseitcannotverifythefirst(root)Certificate(modelCA)

Page 39: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

39

client

AclientconnectsifthemodelCAscertificateisknown

Page 40: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

40

https://localhost:44330

Page 41: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

41

https://cse.iitm.ac.in:44330

Page 42: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

42

RegistermodeCAinyoursystem(needtoselectthatyoutrustthisCA)

Page 43: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

43

https://cse.iitm.ac.in:44330

Page 44: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Attacker forwards authentic certificate

44

3,VerifyIdentityofAlice4.DigitallySign

Bank.com

Page 45: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Attacker changes public key with her own

45

3,VerifyIdentityofAlice4.DigitallySign

RequestatCAisgoingtobefailBecausesignaturedoesnotmatchpublickey

Bank.com

Page 46: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Attacker sends her own public key + signature

46

3,VerifyIdentityofAlice4.DigitallySign

Verifyshouldfail

Bank.com

Page 47: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

47

Alice’scertificateSignedbyCA

Consider this Situation

Bank.comCertificateSignedbyCA

Bank’scertificate

1.  Attackermodifiespublickeys2.  AttackerreplacesBob’scertificatewithhis/herown

Page 48: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

48

Alice’scertificateSignedbyCA

Consider this Situation

Bank’scertificate

1.  Attackerforwardsfakecertificate2.  AttackerreplacesBob’scertificatewithhis/herown

(WhatistherequirementtohaveaMIMA?)

Bank.comCertificateSignedbyCA

Page 49: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Attacker Sends His/Her Own Certificate

•  Attacker’scertificateisvalid.•  BrowserchecksiftheidentityspecifiedinthesubjectfieldofthecertificatematchestheAlice’sintent.•  Thereisamismatch:attacker.com≠example.com

•  Browserterminateshandshakeprotocol:MITMfails

Page 50: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Emulating an MITM Attack •  DNSAttackisatypicalapproachtoachieveMITM

•  WeemulateanDNSattackbymanuallychangingthe/etc/hostsfileontheuser’smachinetomapexample.comtotheIPaddressoftheattacker’smachine.

•  Onattacker’smachinewehostawebsiteforexample.com.•  Weusetheattacker’sX.509certificatetosetuptheserver•  TheCommonnamefieldofthecertificatecontainsattacker32.com

•  Whenwevisitexample.com,wegetanerrormessage:

Page 51: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Attacks Surfaces on PKI

Page 52: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Attack on CA’s Verification Process

• CA’sjobhastwoparts:•  Verifytherelationshipbetweencertificateapplicantandthesubjectinformationinsidethecertificate

•  Putadigitalsignatureonthecertificate

•  Casestudy:ComodoBreach[March2011]•  PopularrootCA.•  TheapprovalprocessinSouthernEuropewascompromised.•  Ninecertificateswereissuedtosevendomainsandhencetheattackercouldprovidefalseattestation.

•  Oneoftheaffecteddomain(akeydomainfortheFirefoxbrowser):addons.mozilla.org

Page 53: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Attack on CA’s Signing Process

•  IftheCA’sprivatekeyiscompromised,attackerscansignacertificatewithanyarbitrarydatainthesubjectfield.

•  CaseStudy:theDigiNotarBreach[June-July2011]

•  AtopcommercialCA•  AttackergotDigiNotar’sprivatekey•  531roguecertificateswereissued.•  TrafficintendedforGooglesubdomainswasintercepted:MITMattack.

•  HowCAsProtectTheirPrivateKey•  HardwareSecurityModel(HSM)

Page 54: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Attacks on Algorithms

•  DigitalCertificatesdependontwotypesofalgorithms•  one-wayhashfunctionanddigitalsignature

•  CaseStudy:theCollision-ResistantPropertyofOne-WayHash•  AtCRYPTO2004,XiaoyunWangdemonstratedcollisionattackagainstMD5.•  InFebruary2017,GoogleResearchannouncedSHAtteredattack

•  Attackbrokethecollision-resistantpropertyofSHA-1•  TwodifferentPDFfileswiththesameSHA-1haswascreated.

• Countermeasures:usestrongeralgorithm,e.g.SHA256.

Page 55: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Attacks on User Confirmation

•  Afterverifyingthecertificatefromtheserver,clientsoftwareissurethatthecertificateisvalidandauthentic

•  Inaddition,thesoftwareneedstoconfirmthattheserveriswhattheuserintendstointeractwith.

•  Confirmationinvolvestwopiecesofinformation

•  Informationprovidedorapprovedbyuser•  Thecommonnamefieldinsidetheserver’scertificate•  Somesoftwaredoesnotcomparethesetwopiecesofinformation:securityflaw

Page 56: Public Key Infrastructurechester/courses/19e_ns/slides/7_PKI.pdf · Attacks Surfaces on PKI . Attack on CA’s Verification Process • CA’s job has two parts: • Verify the relationship

Attacks on Confirmation: Case Study PhishingAttackonCommonNamewithUnicode

•  ZhengfoundoutseveralbrowsersdonotdisplaythedomainnamecorrectlyifnamecontainsUnicode.

•  xn—80ak6aa92e.comis encoded using Cyrillic characters. But domain name displayed by browser likes like apple.com

•  Attack:•  Getacertificateforxn—80ak6aa92e.com•  Getusertovisitxn—80ak6aa92e.com,sothecommonnameismatched•  User’sbrowsershowsthatthewebsiteisapple.com.Usercanbefooled.

•  Hadthebrowsertoldtheuserthattheactualdomainisnottherealapple.com,theuserwouldstop.