Transcript
Page 1: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

AuthenticatedEncryptioninSSH

KennyPaterson

InformationSecurityGroup

@kennyog;www.isg.rhul.ac.uk/~kp

Page 2: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Overview(bothlectures)

•  Securechannelsandtheirproperties•  AEAD(revision)•  AEAD≠securechannel–the[APW09]attackonSSH

•  ThestateofAEADinSSHtoday•  AnewattackonCBC-modeinOpenSSH

•  SecurityanalysisofotherSSHandOpenSSHmodes–CTR,ChaChaPoly,gEtM,AES-GCM.

2

Page 3: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Securechannelsandtheirproperties

Page 4: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Whydoweneedsecurechannels?

•  Securecommunicationsisthemostcommonreal-worldapplicationofcryptographytoday.

•  Securecommunicationssystemsareextremelywidely-deployedinpractice:

•  SSL/TLS,DTLS,IPsec,SSH,OpenVPN,…•  WEP/WPA/WPA2•  GSM/UMTS/4g/LTE•  Cryptocat,OTR,SilentCircle•  OpenPGP,iMessage,Telegram,Signal,anda

thousandothermessagingapps•  QUIC,MinimalT,TCPcrypt

44

Page 5: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Securityproperties

•  Confidentiality–privacyfordata•  Integrity–detectionofdatamodification

•  Authenticity–assuranceconcerningthesourceofdata

55

Page 6: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Somelessobvioussecurityproperties

•  Anti-replay•  Detectionthatmessageshavebeenrepeated.

•  Detectionofdeletion•  Detectionthatmessageshavebeendeletedbythe

adversaryordroppedbythenetwork.

•  Detectionofre-0rdering•  Ensuringthattherelativeorderofmessagesineach

directiononthesecurechannelispreserved.•  Possiblyre-orderingtheeventofviolation.

•  Preventionoftraffic-analysis.•  Usingtrafficpaddingandlength-hidingtechniques.

66

Page 7: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Possiblefunctionalityrequirements

•  Speedy•  Low-memory

•  On-line/parallelisablecrypto-operations•  Performanceisheavilyhardware-dependent.

•  Mayhavedifferentalgorithmsfordifferentplatforms.

•  IPR-friendly•  Thisissuehassloweddownadoptionofmany

otherwisegoodalgorithms,e.g.OCB.

•  Easytoimplement•  Withoutintroducinganyside-channels.

77

Page 8: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Additionalrequirements

•  Weneedacleanandwell-definedAPI.

•  Becausetherealityisthatoursecurechannelprotocolwillprobablybeusedblindlybyasecurity-naïvedeveloper.

•  Developerswantto“open”and“close”securechannels,andissue“send”and“recv”commands.

•  They’dliketosimplyreplaceTCPwitha“secureTCP”havingthesameAPI.

•  Ortojusthaveablack-boxfordeliveringmessagessecurely.

88

Page 9: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

AdditionalAPI-drivenrequirements

•  Doesthechannelprovideastream-basedfunctionalityoramessage-orientedfunctionality?

•  Doesthechannelacceptmessagesofarbitrarylengthandperformitsownfragmentationandreassembly,oristhereamaximummessagelength?

•  Howiserrorhandlingperformed?Isasingleerrorfatal,leadingtotear-downofchannel,oristhechanneltolerantoferrors?

•  Howaretheseerrorssignalledtothecallingapplication?Howshouldtheprogrammerhandlethem?

•  Doesthesecurechannelitselfhandleretransmissions?Oristhislefttotheapplication?Orisitguaranteedbytheunderlyingnetworktransport?

•  Doesthechannelofferdatacompression?•  Thesearedesignchoicesthatallimpactonsecurity•  Theyarenotwell-reflectedinthesecuritydefinitionsfor

symmetricencryption99

Page 10: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

AEAD(Revision)

Page 11: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption

11

m1

m2

PicturesbyGiorgiaAzzurraMarson

Page 12: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption

12

m1

m2

K K

KE

Ch

Page 13: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption

13

c1

c2

K KCh

c1=EncK(m1)

m2=DecK(c2)

m1=DecK(c1)

c2=EncK(m2)

Page 14: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption–Confidentiality

14

c1

c2

K KCh

c1=EncK(m1)

m2=DecK(c2)

m1=DecK(c1)

c2=EncK(m2)

EncOracle

learnbin{0,1}fromc*=EncK(mb)

IND-CPA(Goldwasser-Micali,1984;Bellare-Desai-Jokipii-Rogaway,1997).

Page 15: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption–Confidentiality

15

c1

c2

K KCh

c1=EncK(m1)

m2=DecK(c2)

m1=DecK(c1)

c2=EncK(m2)

EncOracle

learnbin{0,1}fromc*=EncK(mb)

IND-CPA(Goldwasser-Micali,1984;Bellare-Desai-Jokipii-Rogaway,1997).

DecOracle

IND-CCA(Naor-Yung,1990;

Rackoff-Simon,1997).

Page 16: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption–Integrity

16

c1

c2

K KCh

c1=EncK(m1)

m2=DecK(c2)

m1=DecK(c1)

c2=EncK(m2)

Isthiswhatyouwrote?

Page 17: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption–Integrity

17

c1

c2

K KCh

c1=EncK(m1)

m2=DecK(c2)

m1=DecK(c1)

c2=EncK(m2)

EncOracle

comeupwithvalidc*

DecOracle

INT-CTXT(Bellare,Rogaway,2000)

Page 18: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption–Integrity

18

c1

c2

K KCh

c1=EncK(m1)

m2=DecK(c2)

m1=DecK(c1)

c2=EncK(m2)

EncOracle

comeupwithvalidc*foranewm*

DecOracle

INT-CTXT(Bellare,Rogaway,2000)

INT-PTXT(Bellare-Namprempre,2000)

Page 19: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption–AE

19

c1

c2

K KCh

c1=EncK(m1)

m2=DecK(c2)

m1=DecK(c1)

c2=EncK(m2)

EncOracle DecOracle

INT-CTXT(Bellare,Rogaway,2000)

INT-PTXT(Bellare-Namprempre,2000)

AuthenticatedEncryptionIND-CPA+INT-CTXT

(èIND-CCA)

Page 20: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption–AEAD

20

c1

c2

K KCh

c1=EncK(AD1,m1)

m2=DecK(AD2,c2)

m1=DecK(AD1,c1)

c2=EncK(AD2,m2)

EncOracle DecOracle

AuthenticatedEncryptionwithAssociatedDataAEsecurityformessagem

IntegrityforassociateddataADStrongbindingbetweencandAD

(Rogaway2002)

Page 21: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Whichcamefirst?

SecurityforSymmetricEncryption–statefulAEAD

21

c1

c2

K KCh

c1=EncK(AD1,m1)

m2=DecK(AD2,c2)m3=DecK(AD3,c3)

m1=DecK(AD1,c1)

c2=EncK(AD2,m2)c3=EncK(AD3,m3)

c3

Page 22: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption–statefulAEAD

22

c1

c2

K KCh

c1=EncK(AD1,m1)

m2=DecK(AD2,c2)m3=DecK(AD3,c3)

m1=DecK(AD1,c1)

c2=EncK(AD2,m2)c3=EncK(AD3,m3)

c3

EncOracle DecOracle

learnbin{0,1}fromc*=EncK(mb)

IND-sfCCA (Bellare-Kohno-Namprempre,2002)

Page 23: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption–statefulAEAD

23

c1

c2

K KCh

c1=EncK(AD1,m1)

m2=DecK(AD2,c2)m3=DecK(AD3,c3)

m1=DecK(AD1,c1)

c2=EncK(AD2,m2)c3=EncK(AD3,m3)

c3

EncOracle DecOracle

learnbin{0,1}fromc*=EncK(mb)orcomeupwith

valid/outoforderc*

IND-sfCCA (Bellare-Kohno-Namprempre,2002)

INT-sfCTXT

INT-sfPTXT(Brzuska-Smart-Warinschi-Watson,2013)

StatefulAEAD

Page 24: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption–nonce-basedAEAD

24

c1

c2

K KCh

c1=EncK(N1,AD1,m1)

m2=DecK(N2,AD2,c2)

m1=DecK(N1,AD1,c1)

c2=EncK(N2,AD2,m2)

EncOracle DecOracle

Nonce-basedAuthenticatedEncryptionwithAssociatedDataAsperAEAD,butwithadditionalinputNtoEncandDecalgorithms

AdversarymayarbitrarilyspecifyN,but“norepeats”ruleEncandDeccannowbestatelessanddeterministic

(Rogaway2004)

Page 25: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityforSymmetricEncryption–furthernotions

25

•  LH-(stateful)AE(AD)•  Ontopofeverythingelse,ciphertextsprovidea

modicumofhidingofplaintextlengths.

•  cfvariablelengthpaddinginSSL/TLS.

•  IntroducedbyPaterson-Ristenpart-Shrimpton,2011.

•  IncorporatedintoACCEframeworkforanalysisofTLSbyJager-Kohlar-Schage-Schwenk,2012.

Page 26: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

CAESAR

26

•  CAESAR:CompetitionforAuthenticatedEncryption:Security,Applicability,andRobustness.

•  InitiatedbyDanBernstein,supportedbycommitteeofexperts.

•  MaingoalisthedesignofaportfolioofAEschemes.•  CAESARhasinvolveddozensofperson-yearsofeffort

andledtoamajoruptickinresearchactivity.

•  Itseemsthatmostofthecryptographiccommunityhassettledonnonce-basedAE/AEADastheirworkingabstraction.

Page 27: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

AEAD≠securechannel–the[APW09]attackonSSH

Page 28: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

AEAD≠securechannel

•  Recallourapplicationdeveloper:•  Hewantsadrop-inreplacementforTCPthat’ssecure.

•  Actually,hemightjustwanttosendandreceivesomeatomicmessagesandnotaTCP-likestream.

•  TowhatextentdoesAEADmeettheserequirements?

•  Itdoesn’t…

28

Page 29: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

AEAD≠securechannel

There’sasignificantsemanticgapbetweenAEAD’sfunctionalityandrawsecurityguarantees,andallthethingsadeveloperexpectsasecurechanneltoprovide.

29

m1

m2

ChEnc(.,.,.)

Dec(.,.,.)

+

Page 30: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

IntroductiontoSSH

30

Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices. Used primarily on Linux and Unix based systems to access shell accounts, SSH was designed as a replacement for TELNET and other insecure remote shells, which send information, notably passwords, in plaintext, leaving them open for interception. The encryption used by SSH provides confidentiality and integrity of data over an insecure network, such as the Internet.

– Wikipedia

Page 31: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SSHBinaryPacketProtocol(RFC4253)

•  Encode-then-E&Mconstruction,statefulbecauseofinclusionof4-bytesequencenumber.

•  Packetlengthfieldmeasuresthesizeofthepacket:|PadLen|+|Payload|+|Padding|.•  Encrypted,sosequenceofencryptedpacketslookslikealongstringofrandombytes.

•  EncryptionoptionsinRFC4253:CBCmode;RC4.•  AES-CTRdefinedinRFC4344.31

Encrypt

PRF-MAC

Payload

Ciphertext MAC tag

Sequence Number 4

Packet Length 4

Pad Len 1

Padding ≥4

Page 32: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

CBCmodeinSSH

32

•  RFC4253mandates3DES-CBCandrecommendsAES-CBC.

•  SSHusesachainedIVinCBCmode:–  IVforcurrentpacketisthelast

ciphertextblockfromthepreviouspacket.

–  EffectivelycreatesasinglestreamofdatafrommultipleSSHpackets.

Ci-1 Ci

Pi-1 Pi

dK dK

Pi-1 Pi

Ci-1 Ci

eK eK

Page 33: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

CTRmodeinSSH

33

•  CTRmodeusesblockciphertobuildastreamcipher.

•  CTRmodeforSSHisstandardisedinRFC4344.•  Initialvalueofcounteris

obtainedfromhandshakeprotocol.

•  Counterrunsacrosspackets.•  Packetformatispreservedfrom

CBCcase.•  RFCrecommendsuseofAES-

CTRwith128,192and256-bitkeys,and3DES-CTR.

Ci

eK

Pi

ctr+i

Pi

eK

Ci

ctr+i

Page 34: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SSHBinaryPacketProtocol(RFC4253)

•  IVchainingattack:•  Chosenplaintext,distinguishingattackduetoRogaway,appliedtoSSHin[BKN02].•  NotfullyrealisticforSSHbecauseofformatrequirementsonthefirstblockof

plaintextandbecauseofchosenplaintextrequirement.•  ConstructionwithrandomIVsisIND-sfCCAsecure[BKN02].

34

Encrypt

PRF-MAC

Payload

Ciphertext MAC tag

Sequence Number 4

Packet Length 4

Pad Len 1

Padding ≥4

Page 35: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SSHBinaryPacketProtocol(RFC4253)

•  Howdoesdecryptionwork?•  Recall:receivergetsastreamofbytes,andasingleciphertext

canbefragmentedoverseveralTCPmessages.

35

Encrypt

PRF-MAC

Payload

Ciphertext MAC tag

Sequence Number 4

Packet Length 4

Pad Len 1

Padding ≥4

Page 36: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

BreakingCBCmodeinSSH[APW09]

36

IV Ci*

P0’

dK

•  Thereceiverwilltreatthefirst32bitsofthecalculatedplaintextblockasthepacketlengthfieldforthenewpacket.

•  Here: P0’=IV⊕dK(Ci*)whereIVisknown.

Targetciphertextblockfromstream

Lengthfield

Page 37: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

BreakingCBCmodeinSSH[APW09]

37

IV Ci*

P0’

dK

R R

P2’

dK dK

P1’

Theattackerthenfeedsrandomblockstothereceiver–  Oneblockatatime,waitingtoseewhathappensattheserver

wheneachnewblockisprocessed–  ThisispossiblebecauseSSHrunsoverTCPandtriestodoonline

processingofincomingblocks

Page 38: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

BreakingCBCmodeinSSH[APW09]

38

IV Ci*

P0’

dK

•  Onceenoughdatahasarrived,thereceiverwillreceivewhatitthinksistheMACtag–  TheMACcheckwillfailwithoverwhelmingprobability–  Consequentlytheconnectionisterminated(withanerrormessage)

•  Howmuchdatais“enough”sothatthereceiverdecidestochecktheMAC?

•  Answer:whateverisspecifiedinthelengthfield:

R R

P2’

dK dK

P1’

MAC tag

Page 39: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

BreakingCBCmodeinSSH[APW09]

39

IV Ci*

P0’

dK

Ci-1* Ci

*

Pi*

dK

•  KnowingIVand32bitsofP0’,theattackercannowrecover

32bitsofthetargetplaintextblockPi*:

Pi*=Ci-1

*⊕dK(Ci*)=Ci-1

*⊕IV⊕P0’

Page 40: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Furtherdetails

•  Theattackasdescribedrequirestheinjectionofcirca231bytesofciphertext(expectedvalueoflengthfield).

•  Itrecovers32bitsofplaintextwithprobability1.

•  AndleadstoanSSHconnectionteardown(onMACfailure).

•  TheattackworkswithrandomIVstoo,breakingtheschemethatwasprovensecurein[BKN02].

•  Somethingwentwrongsomewhere!

40

Page 41: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Furtherdetails–Lengthchecking

•  RFC4253requiresimplementationstocheckthatlengthfieldis“reasonable”.

•  Detailsareimplementation-specific.

•  Backin2009,theleadingimplementationwasOpenSSH,thenatversion5.1.

•  AccordingtoSSHwebpage,80%ofserversontheInternetwereusingOpenSSHaroundthattime.

41

Page 42: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Furtherdetails–LengthcheckinginOpenSSH

•  OpenSSH5.1performstwolengthchecksonthelengthfield(LF)whendecryptingthefirstciphertextblock:

•  Check1:5≤LF≤218.

•  Check2:totallength(4+LF)isamultipleoftheblocksize:

LF+4modBL=0.

•  Eachcheckproducesadifferenterrormessageonthenetwork,distinguishablebyattacker.

•  Ifbothcheckspass,thenOpenSSHwaitsformorebytes,thenperformsMACcheck,resultinginathirdkindoferrormessage.

42

Page 43: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Furtherdetails–LengthcheckinginOpenSSH

•  Check1(5≤LF≤218)passeswithprobabilityapprox.2-14.

•  Ifitpasses,thenwithhighprobability,14MSBsofLFare“0”.•  Pass/faildetectableviaerrormessage.

•  Henceattackwithsuccessprob.2-14recovering14bitsofconfirmedplaintext.

•  Check2(LF+4modBL=0)passeswithprobability1/BL,typically2-3or2-4.•  Ifitpasses,thensome(3or4)LSBsofLFarerevealed.

•  Pass/faildetectableviaerrormessage/connectionenteringwaitstate.

•  Ifwaitstateisentered,thentheattackproceedsasbefore.

•  Overall,theattackonOpenSSH5.1recovers32bitsofplaintextwithprob.2-18(forBL=16)andrequiresinjectionofatmost218bytesofdata.

43

Page 44: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Doestheattackmatter?

•  Ontheonehand,theattackhaslowsuccessrate,onlyrecovers32bitsofplaintext,andcausestheSSHconnectiontoabort.

•  Ontheotherhand,anattackercanapplytheattacktomanyconnections,boostinghisoverallsuccessrate.

•  Canalsoiteratetheattackagainstclientsthatperformauto-reconnects.

•  ThinkaboutwhatkindsofdataSSHmightbeprotecting.•  SSHwasmeanttobebullet-proof;theattackshoweditwasnot.

•  ItlefttheprovablesecurityoftheSSHBPPunresolved.44

Page 45: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Countermeasurestotheattack

•  AbandonCBC-mode?•  Alternativesavailableatthattime:CTR,RC4.

•  DropbearimplementedCTRandrelegatedCBCmodeinversion0.53.

•  Developnewmodes?•  ModesbasedonGenericEtM,AES-GCM,ChaCha20-Poly1305

weresubsequentlyaddedtoOpenSSH.

•  PatchCBC-mode?•  OpenSSH5.2alsointroducedapatchtostopthespecificattack

onCBCmode.

45

Page 46: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

TheOpenSSHpatch

•  Basicidea:hidetheerrorsfromtheadversary.•  Ifthelengthchecksfail,donotsendanerrormessage,but

waituntil218byteshavearrived,thenchecktheMAC.

•  Ifthelengthcheckspass,buttheMACcheckeventuallyfails,thenwaituntil218byteshavearrived,thenchecktheMAC.

•  Noerrormessageiseversentuntil218bytesofciphertexthavearrived.

•  CannolongercountbytestoseehowmanyarerequiredtotriggerMACfailure.

46

Page 47: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

TheorylessonfromtheSSHattack

•  Modelusedforsecurityproofin[BKN02]wasinadequate.•  Itassumedlengthwasknownandatomicprocessingof

ciphertexts.

•  ButfragmentedadversarialdeliveryofciphertextoverTCPispossible.

•  Implementationshavetodecryptfirstblocktofindouthowlongplaintextismeanttobe,andactonitbeforeperforminganyauthentication.

•  That’snotreflectedinanyoftheAE/AEADsecuritymodels!

•  Andthere’snoCAESARrequirementthatlookslikethis!

47

Page 48: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

TheStateofAEADinSSHToday

Page 49: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

ThestateofAEADinSSHtoday

•  In[ADHP16],weperformedameasurementstudyofSSHdeployment.

•  WeconductedtwoIPv4addressspacescansinNov/Dec2015andJan2016usingZGrab/ZMap.

•  GrabbingbannersandSSHservers’preferredciphers.•  ActualcipherusedinagivenSSHconnectiondependsonclient

andserverpreferences.

•  Roughly224serversfoundineachscan.

•  Nmapfingerprintingsuggestsmostlyembeddedrouters,firewalls.

49

Page 50: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

ThestateofAEADinSSHtoday:SSHversions

50

MostlyOpenSSHanddropbear;others

lessthan5%.

Page 51: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

ThestateofAEADinSSHtoday:SSHversions

51

Dropbearat56-58%.886kolderthenversion0.53,sovulnerabletovariantof2009CBC-

modeattack!

Page 52: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

ThestateofAEADinSSHtoday:SSHversions

52

OpenSSHat37-39%.130-166kolderthenversion5.2andprefer

CBCmode,sovulnerableto2009

attack!

Page 53: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

ThestateofAEADinSSHtoday:SSHversions

•  DropbearnowdominatesOpenSSH.•  Butmaybeswitchingbackagain:ComcastcableIPaddress

rangedroppedfrom2M+devicesrunningDropbear(Feb2016)to83k(May2016).

•  Longtailofoldsoftwareversions.•  MostpopularversionofOpenSSHisversion5.3,releasedOct

2009(currentversionis7.2).

•  DeterminedbymajorLinuxdistros?

•  SignificantpercentageofDropbearandOpenSSHserversarepotentiallystillvulnerabletothe2009attack.•  8.4%forDropbear.

53

Page 54: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

ThestateofAEADinSSHtoday:preferredalgorithms

54

OpenSSH preferred algorithms

•  Lotsofdiversity,surprisingamountof“genericEtM”(gEtM).

•  CTRdominates,followedbyCBC.

•  ChaCha20-Poly1305ontherise?(becamedefaultinOpenSSH6.9).

•  SmallamountofGCM.

Page 55: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

ThestateofAEADinSSHtoday:preferredalgorithms

55

Dropbear preferred algorithms

•  LessdiversitythanOpenSSH.

•  CTRdominates,followedatalongdistancebyCBC.

•  No“exotic”options.

Page 56: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

ANewAttackonCBCmodeinOpenSSH

Page 57: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

TheOpenSSHpatch

•  Version5.2+CBCmodepreferredbyroughly20kOpenSSHservers.

•  RecalltheOpenSSHpatch,inversion5.2andup:•  Ifthelengthchecksfail,donotsendanerrormessage,butwait

until218byteshavearrived,thenchecktheMAC.

•  Ifthelengthcheckspass,buttheMACcheckeventuallyfails,thenwaituntil218byteshavearrived,thenchecktheMAC.

•  OneMACcheckisdoneiflengthchecksfail:on218bytes.

•  TwoMACchecksaredoneiflengthcheckspass:oneonroughlyLFbytes,theotheron218bytes.

57

Page 58: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

AttackingtheOpenSSHpatch[ADHP16]

•  ThisleadstoatimingattackonCBCmodeinOpenSSH5.2andup:1. InjecttargetciphertextblockCi

*.2. Thensend218bytesasquicklyaspossibletoserver.

3. TimethearrivaloftheMACfailuremessage.

•  FastarrivalindicatesthatlengthchecksfailedandoneMACcomputation.

•  SlowarrivalindicatesthatthelengthcheckspassedandtwoMACcomputations.

•  Thisleaks18bitsofinformationaboutthelengthfield,andhence18bitsaboutthetargetblock.

58

Page 59: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

AttackingtheOpenSSHpatch[ADHP16]

•  Sizeoftimingdifference:•  AMACcomputationonroughly217bytes(theexpectedvalueofLF).

•  ForHMAC-SHA1,thisrequires211hashcompressionfunctionevaluations.

•  cf.Lucky13timingdifference:asinglehashcompressionfunction!

•  Remoteattackercaneasilydetectdifference.

•  Successprobabilityoftheattack:•  Needtopassbothlengthchecks,so2-18.

•  Canincreasesuccessrategivenpartialplaintextknowledgeintargetblock.

•  (Idea:waitfortherightIVbeforemountingtheattack;moresevereattackforrandom,explicitIVversion.)

59

Page 60: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

AttackingtheOpenSSHpatch[ADHP16]

•  Increasenumberofplaintextbitsrecoveredbyusingfiner-grainedtiminginformation.•  BecausethetimingdelayisproportionaltothevalueofLF.

•  Iftiminggranularity=1compressionfunctionevaluation,thenwecanrecoverupto30bitsofplaintextfromtargetblock.

•  Challenging,butnotimpossibleinco-residentattackerscenario.

•  Possiblecountermeasuretotheattack:ifMACfails,thencomputesecondMACon218–LFbytesinsteadofonall218bytes.

•  StillleavesresidualtimingdifferencebecauseoffinedetailsofHMAC.

•  Reallyneedconstanttimeimplementationofdecryptionalgorithmtoeliminatethisclassofattack.

60

Page 61: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Disclosureoftheattack

•  WenotifiedtheOpenSSHteamoftheattackon5thMay2016.

•  TheyareconsideringaddingcountermeasuresforthenextreleaseofOpenSSH(7.3).

•  “…wedonotfeelthatanemergencyreleaseisnecessary,northattheattackremainsecretaheadofsucharelease.”

•  OpenSSHhassteadilybeendeprecatingoldalgorithmsandmodes.

•  CBCmodewasalreadydisabledbydefaultinOpenSSH6.7(butcanbere-enabled).

•  ButOpenSSHcannotforcepeopletostopusingoldversionsofthesoftware.

61

Page 62: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityanalysisofotherSSHandOpenSSHmodes–CTR,gEtM,AES-GCM,ChaCha20Poly1305

Page 63: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Securityanalysisofotherencryptionmodes

•  The[APW09]attacksexploitstheattacker’sabilitytodeliverciphertextfragmentsandthe“cut-and-paste”propertiesofCBC-mode:

•  Decryptionoftargetblockinwrongpositionismeaningfullyrelatedtoitsdecryptionintrueposition:

63

IV Ci*

P0’

dK

Ci-1* Ci

*

Pi*

dK

Page 64: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Securityanalysisofotherencryptionmodes

•  ThecutandpastepropertydoesnotholdforCTRmode.

•  InsertingCi*inthestreamresultsinunrelatedplaintext:

P0’=Ci

*⊕eK(ctr0)=Pi*⊕eK(ctri)⊕eK(ctr0)

•  ButisCTRmodesecureagainstanadversarywhocandeliverciphertextinafragmentedfashion?

•  Classicalsecuritymodelsforsymmetricencryptioncannottellustheanswer.

•  AndwhatabouttheothermodesthathavebeenaddedtoOpenSSHsince2009?•  gEtM,AES-GCM,ChaCha20Poly1305.

64

Page 65: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityanalysisofCTRmodeinSSH

•  [PW10]developedabespokesecuritymodelforCTRmodeinSSHandproveditsecure(assumingblockcipherisaPRP).

•  Themodelallowstheattackertodeliverciphertextstodecryptionoracleinabyte-by-bytefashion.

•  DecryptionoracleintendedtoaccuratelymodelOpenSSH’sCTRmodeimplementation.

•  Sanitycheckingoflengthfield,withrelatederrormessages,MACfailures,etc.

•  Complexpseudo-codedescriptionsofalgorithmsandoracles.

65

Page 66: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityanalysisofotherOpenSSHencryptionmodes

•  [BDPS12]developedageneralframeworkforstudying“SymmetricEncryptionschemessupportingfragmenteddecryption”.

•  TheIND-CFAmodelallowstheattackertodeliverciphertexttoadecryptionoracleinasymbol-by-symbolfashionandobserveanyerrors/messageoutputs.

•  [BDPS12]alsoidentifiedadditionalsecuritypropertiesthatSSHattemptstoprovide:•  BoundaryHiding(BH)andDenial-of-Serviceresistance.

66

Page 67: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityanalysisofotherOpenSSHencryptionmodes

•  [ADHP16]usedtheframeworkof[BDPS12]tostudygEtM,AES-GCM,andChaCha20-Poly1305inOpenSSH.

•  gEtMandAES-GCM:•  DerivedfromAEADschemeswithAD=lengthfield(nowunencrypted).

•  Hencesanitycheckingoflengthfieldcannotrevealanythingusefultoadversary.

•  IssueinOpenSSHcodeforgEtM:becauseofsharedpathwithlegacyE&Mcode,theMACiscomputedoncetheciphertexthasarrivedbutisnotcomparedtoreceivedMACuntilafterdecryption.

•  Henceanyerrorsarisingduringdecryptionstepwillbesignalledtoattacker.

•  Notasecuritythreatforanycurrentlyspecifiedencryptionschemes.

•  Both(fixed)gEtMandAES-GCMareprovablysecure.

67

Page 68: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

ChaCha20-Poly1305inOpenSSH

68

Payload

MAC tag

SQN 4

Packet Length 4

Pad Len 1

Padding ≥4

C1 C2

K1IV = SQN||064 ChaCha20 ChaCha20

K2IV = SQN||0631

ChaCha20 K2

IV = SQN||0630

0256

KpolyPoly1305

Page 69: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

SecurityanalysisofChaCha20-Poly1305inOpenSSH

•  ChaCha20-Poly1305inOpenSSH:•  64-bytekeyissplitintotwohalves,K1,K2.

•  K1usedtoencryptSSHlengthfieldusingChaCha20.

•  K2usedtoencrypteverythingelse,alsousingChaCha20.

•  Poly1305MACkeyisobtainedas:

ChaCha20(K2,IV=SQN||0630,M=0256).

•  MACappliedtobothciphertextcomponents.

•  Analysismorecomplexbecauseofencryptedlengthfield.

•  Ideaisthatusingseparatekeysforencryptinglengthfieldandthereststopsattacks.

•  CTRmodeanalysisshowsthistobeunnecessary.

69

Page 70: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Closingremarks

Page 71: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Closingremarks

•  Simplesecuritymodelsforsymmetricencryptionversuscomplexsecuritypropertiesdesiredofsecurechannels.

•  Infact,ourmodelsforsecurechannelsarestillevolving...

•  Thereismuchyettobedonehere,butcommunity’sfocusiscurrentlymostlyonAEAD.

•  Keytake-aways:

•  Takecryptographer’sabstractionswithapinchofsalt.

•  Thinktop-down,andonlybottom-up(fromAPItocrypto,notthereverse).

71

Page 72: Authenticated Encryption in SSH · Introduction to SSH 30 Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices

Closingremarks

72


Top Related