HTTP Digest Integrity
HTTP Digest Integrity
Contents
Introduction.....................................................................................................................................................1 Overview of HTTP Digest Authentication..................................................................................................1 RFC 2069 Mode.................................................................................................................................................................................1 auth Mode...........................................................................................................................................................................................2 auth-int Mode.....................................................................................................................................................................................2 Related Attacks...............................................................................................................................................3 SSL/TLS Renegotiation.....................................................................................................................................................................3 HTTP Request Smuggling................................................................................................................................................................4 Mitigation with Digest Authentication.........................................................................................................6 Limitations.......................................................................................................................................................6 Conclusion........................................................................................................................................................7 Acknowledgements........................................................................................................................................7 References........................................................................................................................................................8
H T T P D I G E S T I N T E G R I T Y : A N O T H E R L O O K , I N L I G H T O F R E C E N T AT TA C K S
VERSION 1.0
J A N U A RY 5 , 2 0 1 0
Introduction
Recenthistoryhasproventhatwebcommunicationssecurityishighlylackinginredundancy.Thatis,simplebreaks incommonprotocols,suchasSSL/TLSortheauthenticationmechanismswhichsupportit, oftenleadtocata strophic gaps in security. Recent examples of this fragile architecture abound [0Prfx,DebKeys,MD5CA,OCSP3,ReTLS], and even when protocols and implementations themselves are sound, researchindicatesbrowseruserinterfacescontinuetoleaveroomforseriousattacks[SSLWarn]. ThispaperexploreshowtheseldomusedHTTPdigestauthenticationprotocolcanbeusedtomitigatecertainrecent formsofattack,includingSSL/TLSrenegotiationandsometypesofHTTPrequestsmuggling.
C O P Y R I G H T 2 0 1 0 V I RT U A L S E C U R I T Y R E S E A R C H , L L C A L L R I G H T S R E S E RV E D .
1 / 8
H T T P D I G E S T I N T E G R I T Y : A N O T H E R L O O K , I N L I G H T O F R E C E N T AT TA C K S
VERSION 1.0
J A N U A RY 5 , 2 0 1 0
auth Mode
RFC2617introducedrevisionstodigestauthenticationwhichallowforimprovedefficiencyandauthenticationof servers. Whenserversadvertisethe auth or auth-int qualityofprotectionmodes,clientsshouldselectoneof these(asopposedtotheRFC2069mode)andsomeadditionalinformationissentalongtotheserver(andprotected bycryptographichashes): Noncecount Clientnonce
auth-int Mode
Theauth-intmodeisverysimilartotheauthmode,exceptthatitrequirestherequest'sbodyhashbeincluded. ThisissimplyamoreexplicitversionoftheoptionalrequestbodydigestmodedescribedinRFC2069.
C O P Y R I G H T 2 0 1 0 V I RT U A L S E C U R I T Y R E S E A R C H , L L C A L L R I G H T S R E S E RV E D .
2 / 8
H T T P D I G E S T I N T E G R I T Y : A N O T H E R L O O K , I N L I G H T O F R E C E N T AT TA C K S
VERSION 1.0
J A N U A RY 5 , 2 0 1 0
Related Attacks
SSL/TLS Renegotiation
A seriousflawwasrecentlydiscoveredin SSLandTLSwhichallowsanattacker,positionedon thenetworkin betweenaclientandserver,toinitiateaprotocolrenegotiationandinjectasinglebufferofdataintotheencrypted stream. InthecontextofHTTP,thiscouldtaketheformofaforgedHTTPrequestwhichcanbeveryseriousin certainsituations.However,notethatthisvulnerabilitydoesnotpermitanattackertodecryptinformationsubmitted byeithertheclientorserver,unlesssomeadditionalattacksareconductedwhichrelyonsecondarybehaviorsof eithertheclientorserverapplications. Intheoriginalpaper[ReTLS],twoprimaryattackscenariosweredescribed,onewhereaclientisauthenticatedusing a certificate and the other whereclients areauthenticatedusingHTTP session cookies. In theformer case, the injectedrequestautomaticallyhijackstheclient'sidentity,sincetheconnectionitselfisconsideredtrustedbythe serverandnoauthenticationinformationneedbecarriedinHTTPheaders.However,exploitationofthelattercaseis moretricky,sinceablindlyinjectedrequestwouldnotcarrythenecessaryHTTPheaderstohijackauthentication.In thiscase,anattackercaninsteadinjectanincompleterequestwhichfailstoterminateanHTTPheader.Forexample, ifanattackerweretoinjectapartialrequestwhichlookslike: GET /private/importantAction.cgi?do=evil HTTP/1.1 Host: vulnerable.example.com X-ignore: Here,theattacker'sfinallinewouldnotbeterminatedwithanewline.Thefinalcharacteroftheinjecteddatawouldbeaspace. Next,thevictim'sclientsubmitsabenignrequest,perhapslookinglike: GET /private/boringPage.html HTTP/1.1 Host: vulnerable.example.com Cookie: SessionIdentifier=43218730492374928347923847293
Uponreceivingthesetwopacketsandinterpretingthemasacontinuousstream,thewebserverwouldseeasingle requestwhichlookslike: GET /private/importantAction.cgi?do=evil HTTP/1.1 Host: vulnerable.example.com X-ignore: GET /private/boringPage.html HTTP/1.1 Host: vulnerable.example.com Cookie: SessionIdentifier=43218730492374928347923847293
Here,thewebserverwouldignoretheX-ignoreheader(simplybecauseitwouldn'tknowhowtointerpretit)and theremainingheaderssentbythevictimareeffectivelyhijackedforusebytheattackerinwhateverwebapplication actionhechosetoperform.NotethatmosttypicalsessioncookiesandHTTPbasicauthenticationheaderswouldbe primecandidatesforhijacking. Inavariantofthisattack,AnlKurmulaterdemonstratedhowanattackercouldembedavictim'srequestinthe POSTparametersofanevilrequesttogainaccesstothem[TwTLS].Inthisattack,theinjecteddatawouldlooksome thinglike: POST /sendmessage.cgi HTTP/1.0 [email protected]&message=
C O P Y R I G H T 2 0 1 0 V I RT U A L S E C U R I T Y R E S E A R C H , L L C A L L R I G H T S R E S E RV E D .
3 / 8
H T T P D I G E S T I N T E G R I T Y : A N O T H E R L O O K , I N L I G H T O F R E C E N T AT TA C K S
VERSION 1.0
J A N U A RY 5 , 2 0 1 0
Here,thevictim'srequestwouldbeappendedandtreatedasformdatatobeprocessedbyaserver'sscript.InAnl's example,thepopularTwitterwebsitemadejustsuchascriptavailablewhichcouldprovideanattackeraccesstothe POSTedinformation. In [ExpTLS], Thierry Zoller provides detailed explanations of several attack variants. In oneattack, an injected requestwouldbedesignedtoillicitaredirectcodefromtheservertoanunencrypted(nonSSL)webpage.Iftheuser doesnotnoticethattheyarecontinuingtousetheapplicationoveranunecryptedlink,thenthiscouldbeaneffective attackscenariobyforcingallremainingcommunicationstobeunprotectedusingtoolssuchassslstrip[SS]. Inthefinalvariant,anattackerinjectsafullorpartialTRACErequestwhichcontainsaheaderwithJavaScript.Since TRACEresponsesincludesubmittedheadersintheresponsebody,itmaybepossibletoconvincesomebrowsersto executethisclientsidescriptafteritisreturnedbytheserver.Inthiscase,theuser'ssessioncouldbefullyhijacked usingtechniquesakintocrosssitescriptingexploits.
C O P Y R I G H T 2 0 1 0 V I RT U A L S E C U R I T Y R E S E A R C H , L L C A L L R I G H T S R E S E RV E D .
4 / 8
H T T P D I G E S T I N T E G R I T Y : A N O T H E R L O O K , I N L I G H T O F R E C E N T AT TA C K S
VERSION 1.0
J A N U A RY 5 , 2 0 1 0
GET /evil-request.cgi?do-evil=action HTTP/1.0 Content-Length: 0 X-ignore: GET /harmless.html HTTP/1.1 Host: example.com Authorization: Basic {victim's credentials}
WhichofcoursehijackstheusercredentialsinmuchthesamewayassomeTLSrenegotiationattacksdo. Overthelastseveralyears,VSRhasidentifiedcustomproxiesandapplicationswhichsufferfromsimilarvulnerabili tieswhereusersupplieddataisusedinbackendHTTPrequests.Inthesesituations,thesimpleinjectionofnewlines oftenleadstoasimilarresultwithouttheneedforContent-Lengthmanipulation. For example, supposea website helplibrary isdesignedaround a frontendscript which accepts parametersas follows: /FetchHelp.cgi?Topic=Login&lang=es-es Fromthere,thisscriptlooksupthetextforthehelptopic"Login",whichisstoredinEnglishtext.Next,iftheuser doesnotdesireEnglish,itsendsthetextontoathirdpartytranslationservicetoobtainthedesiredversion: POST /translate.cgi?from=en-us&to=es-es HTTP/1.1 Host: translator.example.com Authorization: Basic {credentials for translation service} Content-Length: {length of content below} text={text to be translated} However,sincemostwebframeworksautomaticallydecodeURLparameterspriortopassingthemtocustomscripts, theFetchHelp.cgiscriptmustbeverycarefulabouthowusersuppliedvaluesareforwardedoninthebackend request.Forinstance,ifanattackersendsa"lang"parameterof:
lang=es-es%20HTTP/1.1%0d%0aArbitrary-headers-or:%20request%20splitting%0d%0aXignore: Thentheresultingbackendrequestmightlooklikethefollowingifthescriptfailedtovalidateorreencodethe parameter: POST /translate.cgi?from=en-us&to=es-es HTTP/1.1 Arbitrary-headers-or: request splitting X-ignore: HTTP/1.1 Host: translator.example.com Authorization: Basic {credentials for translation service} Content-Length: {length of content below} text={text to be translated} Whilethisparticularexampleisadmittedlycontrived,severalinstancesofthisstyleofheaderinjectionhavebeen identified in the past, even though these do not appear to be well documented in publicly available security resources.Theresultofthesevulnerabilitiescanvarywidely,dependingonthepurposeofthebackendrequestand theamountofinformationattackerscanobtainonthefrontend. Inpractice,ithasbeenpossibleincustomproxy scenariostosplitHTTPrequestsandfollowupwithasecondfrontendrequesttoobtainresultsfromprevious injectedrequests,providedHTTPsessionsaremaintainedonthebackend.
C O P Y R I G H T 2 0 1 0 V I RT U A L S E C U R I T Y R E S E A R C H , L L C A L L R I G H T S R E S E RV E D .
5 / 8
H T T P D I G E S T I N T E G R I T Y : A N O T H E R L O O K , I N L I G H T O F R E C E N T AT TA C K S
VERSION 1.0
J A N U A RY 5 , 2 0 1 0
Limitations
OnemightbeconvincedatthispointthatHTTPdigestauthenticationishandsdownabettersolutionthanHTTP basicauthentication,andattimes,evencookiebasedsessionmanagement.However,thedevilisinthedetailsand manycommonimplementationsaresimplynotmatureenoughforseamlesseverydayuse. Forexample,accordingto[AMAD],InternetExplorerversions5and6failtoincludetheURI'squerystringinthe digest hash, which creates incompatibilities and limits the efficacy of URI integrity protection. Apache's mod_auth_digest,foritspart,hasstillnotimplementedseveralimportantsecurityfeaturesincludingthe MD5sess algorithm,noncecountchecking,and auth-int support. Mozilla'sFirefoxalsodoesnotappeartosupport auth-int(asofthiswriting)[FFDA],andneitherdoesGoogleChrome[HAHD]. Anotherseriousweakness,commoninmodernbrowsers,isthatnoindicationispresentedtotheuserwhichHTTP authenticationmethod(basicordigest)isbeingused.AsisnotedinRFC2617,maninthemiddledowngradeattacks aretriviallypossible(withoutSSLorotherprotections)byconvincinguserstoauthenticateviabasicauthentication whilesendingthesecredentialstotheserverviadigestauthentication.EvenwiththiswarningpresentintheRFC, manybrowsers(Firefox3.5.6,Opera9.62,GoogleChrome3.0.195.38)simplypresentuserswithagenericprompt,not indicatingwhichmethodisinuse.(Duringlimitedtesting,InternetExplorer8,Opera10.10,andSafari4.0.4atleast
C O P Y R I G H T 2 0 1 0 V I RT U A L S E C U R I T Y R E S E A R C H , L L C A L L R I G H T S R E S E RV E D .
6 / 8
H T T P D I G E S T I N T E G R I T Y : A N O T H E R L O O K , I N L I G H T O F R E C E N T AT TA C K S
VERSION 1.0
J A N U A RY 5 , 2 0 1 0
addedawarningtothepromptwhenbasicauthenticationovernonSSLconnectionswereused.) OveradecadehaspassedsinceRFC2617wasreleased,yetthelackofcompleteand/orcorrectsupportinmain stream browsers and web servers remains a major hinderance for implementors and surely is not encouraging adoption.
Conclusion
HTTP digest authentication should be considered by web application administrators as a temporary mitigation againstSSL/TLSrenegotiationattacks.However,duetopotentialincompatibilities,itshouldbewelltestedpriorto deployment. Inthelongrun,HTTPdigestauthenticationisnotacompletesolutionforbolsteringwebsecurity,butasSSLtech nology showsits age and fragility, web administratorsshould consider layeredapproaches to securing sensitive communications.
Acknowledgements
ThankstoGeorgeGalforassistanceintesting;JoanMorganandJohnRedfordwhoprovidedhelpfulcommentsand suggestions.
C O P Y R I G H T 2 0 1 0 V I RT U A L S E C U R I T Y R E S E A R C H , L L C A L L R I G H T S R E S E RV E D .
7 / 8
H T T P D I G E S T I N T E G R I T Y : A N O T H E R L O O K , I N L I G H T O F R E C E N T AT TA C K S
VERSION 1.0
J A N U A RY 5 , 2 0 1 0
References
0Prfx AMAD DebKeys Null Prefix Attacks Against SSL/TLS Certificates http://www.thoughtcrime.org/papers/null-prefix-attacks.pdf Apache Module mod_auth_digest http://httpd.apache.org/docs/2.2/mod/mod_auth_digest.html When Private Keys are Public: Results from the 2008 Debian OpenSSL Vulnerability https://cseweb.ucsd.edu/~hovav/papers/yrses09.html TLS/SSLv3 Renegotiation Vulnerability Explained http://www.g-sec.lu/practicaltls.pdf Mozilla Cross Reference: nsHttpDigestAuth.cpp http://mxr.mozilla.org/seamonkey/source/netwerk/protocol/http/src/nsHttpDigestAuth.cpp http_auth_handler_digest.cc (Google Chrome) http://src.chromium.org/viewvc/chrome/trunk/src/net/http/http_auth_handler_ digest.cc?revision=26723&view=markup HTTP Request Smuggling http://www.cgisecurity.com/lib/HTTP-Request-Smuggling.pdf MD5 considered harmful today: Creating a rogue CA certificate http://www.win.tue.nl/hashclash/rogue-ca/ Defeating OCSP With the Character '3' http://www.thoughtcrime.org/papers/ocsp-attack.pdf Renegotiating TLS http://extendedsubset.com/Renegotiating_TLS.pdf An Extension to HTTP : Digest Access Authentication http://www.ietf.org/rfc/rfc2069.txt HTTP Authentication: Basic and Digest Access Authentication http://www.ietf.org/rfc/rfc2617.txt Rainbow Table http://en.wikipedia.org/wiki/Rainbow_table SSLSTRIP http://www.thoughtcrime.org/software/sslstrip/ Crying Wolf: An Empirical Study of SSL Warning Effectiveness http://lorrie.cranor.org/pubs/sslwarnings.pdf TLS Renegotiation Vulnerability (CVE-2009-3555) http://www.securegoose.org/2009/11/tls-renegotiation-vulnerability-cve.html Understanding the TLS Renegotiation Attack http://www.educatedguesswork.org/2009/11/understanding_the_tls_renegoti.html Cross-site Tracing http://www.owasp.org/index.php/Cross_Site_Tracing
ExpTLS FFDA
HAHD
XST
C O P Y R I G H T 2 0 1 0 V I RT U A L S E C U R I T Y R E S E A R C H , L L C A L L R I G H T S R E S E RV E D .
8 / 8