using alterna)ve resource locators - black hat briefings...url rewri)ng for good, not evil using...

20
URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL MicrosoA

Upload: others

Post on 24-Mar-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

URLRewri)ngforGood,notEvilUsingAlterna)veResourceLocatorsBryanSullivanSeniorSecurityProgramManager,SDLMicrosoA

Page 2: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

TopWebVulnsHaveaCommonFactor

• Cross‐SiteScrip)ng▫ OWASP#1• Cross‐SiteRequestForgery▫ Growingfast• OpenRedirectPhishing▫ LotsofMSRCcases

[www.owasp.org]

Page 3: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

Propaga)onViaPoisonedHyperlinks

• XSS▫ foo.aspx?bar=<script>alert('xss')</script>• XSRF▫ foo.aspx?ac)on=buy&symbol=GM• RedirectPhishing▫ foo.aspx?target=h_p://evil.com/foo.aspx

• Redirectors(TinyURL,bit.ly)makethingsworse

Page 4: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

BrowserHistoryTheA

• Useanyofthefollowing:▫ Script▫ CSS▫ iframe)minga_acks

• Can’tlistall,butcancheckspecificsitesorsearches▫ www.verylargebank.com▫ www.bing.com/search?q=scarle_+johannson

[popcrunch.com]

Page 5: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

Solu)on:PersonalizeHyperlinks

• NotURLsbutPRLs(PersonalizedResourceLocators)• Maliciouslinkcreatedbyana_ackercouldonlybeusedbyhim/her

• Wealreadyhaveanimplementa)onmechanism:

URLRewri)ng

Page 6: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

URLRewri)nginBrief

h_p://www.site.com/foo.html

h_p://www.site.com/{sessionID}/foo.html

•Thisusuallycausesmoreproblemsthanitsolves▫ Sessionhijacking▫ Sessionfixa)on

Page 7: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

Example

h_p://www.xbox.com/{abc123...}/rockband.aspx

Page 8: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

RewritewithCanary,notSessionID

• Outbound:1. Servercreatessharedsecrettoken(canary)2. Storecanaryvalueinsessionstate3. RewritecanaryintoURL4. PassSIDincookieasusual

• Inbound:1. Servercomparesincomingcanaryagainststored2. Ifmissingormismatched,rejectrequest

Page 9: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

PoisonedLinksareNowUseless

www.site.com/{a1b2...}/foo.aspx?ac)on=buy&symbol=GM

•Senditaroundinanemail•Postitonapage•Hidethepayloadwitharedirector

•Noneofthesema_er,becausevic)mcan’tuseit

Page 10: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

HistoryTheABecomesInfeasible

• AssumeGUIDsareusedforcanaries• A_ackermustcheckallofthese:

www.site.com/{00000000‐0000‐0000‐000000000000}/www.site.com/{00000000‐0000‐0000‐000000000001}/www.site.com/{00000000‐0000‐0000‐000000000002}/

…• 3.4x1038possibili)es▫ Thiswouldtakeareally,reallylong)metocheck

Page 11: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

StatelessAlterna)ve:TimedURLs

• Outbound:1. Getthecurrentdate/)me2. Createakeyedhashofthe)mestamp3. Writethe)mestampandhashintotheURL• Inbound:1. If)mestamporhashmissing,rejectrequest2. If)mestampandhashmismatch,rejectrequest3. If)mestampolderthanspecifiedexpira)onage(ie5

minutes),rejectrequest

Page 12: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

PoisonedLinksareAlmostUseless

h_p://www.site.com/{07.30.2009...}/?ac)on=buy&symbol=GM

•Linksworkforeveryone,butonlyforashortlifespan▫ 5minutesorwhatevertheserverhasconfigured

•Seriouslylimitspoten)aldamage

Page 13: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

HistoryTheAS)llInfeasible

• A_ackermustmakerequests,storekeyedhashes• Assumemillisecondgranularityfor)mestamp• A_ackermustcheckallofthese:

www.site.com/{2009‐07‐30‐T1330000000‐HASH}/www.site.com/{2009‐07‐30‐T1330000001‐HASH}/www.site.com/{2009‐07‐30‐T1330000002‐HASH}/

Page 14: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

AppropriateCryptography

• Youmustincludeahashofthe)mestamp▫ Otherwisea_ackercouldcreatepoisonedURLswitharbitraryexpira)ondates(+10years)

• Youmustkeythehash▫ Otherwisea_ackercouldprecomputeavalidhash• UseSHA‐2▫ Ifyou’regoingtogotothismuchtrouble,useasecurealgorithm

Page 15: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

LandingPages

• Youmustdesignateoneormorepagesas“landingpages”▫ Thesedonotrequirecanariesorkeyed)mestamps▫ Otherwisenoonewillbeabletousethesite

[poandpo.com]

Page 16: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

BypassingDefenses

• ExternalXSSwillcompletelydefeatthesedefenses▫ Landingpage▫ Differentapplica)on,samedomain• UseXSStoinjectXHR▫ Readtoken+redirect▫ Readtoken+modifyDOM

• POSTredirec)onwilldefeat)medURLs

Page 17: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

TemporaryURLBypassTechnique

1. A_ackersetsupmaliciouspage[www.evil.com]2. Whencalled,maliciouspagesendsrequestto

protectedpagetodeterminevalidtoken3. Maliciouspagethenredirectsusertovalidpage

• A_ackernowonlyneedstolureusertohismaliciouspageasusual▫ Phishing,etc

Page 18: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

OtherUnfortunateSideEffects

• Can’temaillinks• Can’tbookmarklinks• Searchenginescan’tindexthesite

Page 19: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

BestUsageScenario

• Don’tapplytoen)resite• Applytosecuresubdomain

• www.verylargebank.com(regularURLs)▫ Loca)ons,hours▫ Currentinterestrates• secure.verylargebank.com(alterna)veURLs)▫ Accountbalances▫ Transfers

Page 20: Using Alterna)ve Resource Locators - Black Hat Briefings...URL Rewri)ng for Good, not Evil Using Alterna)ve Resource Locators Bryan Sullivan Senior Security Program Manager, SDL

Conclusions

• Alterna)veURLscanbeusefulasdefense‐in‐depth• Don’tjustapplythemglobally• Con)nuetofind&fixvulnerabili)es

• Moreresources▫ MSDNMagazine,March2009,SecurityBriefs▫ blogs.msdn.com/sdl▫ Myalias:bryansul