<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Bryan Sullivan's Web Blog</title><subtitle type="html">Thoughts on web application security</subtitle><id>http://blogs.msdn.com/bryansul/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/bryansul/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/bryansul/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2008-03-24T21:43:00Z</updated><entry><title>REST and XSRF, Part One</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/bryansul/archive/2008/08/15/rest-and-xsrf-part-one.aspx" /><id>http://blogs.msdn.com/bryansul/archive/2008/08/15/rest-and-xsrf-part-one.aspx</id><published>2008-08-15T18:46:00Z</published><updated>2008-08-15T18:46:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Hi everyone. In case you missed my talk at &lt;A class="" href="http://www.blackhat.com/" mce_href="http://www.blackhat.com"&gt;Black Hat&lt;/A&gt;, “REST for the Wicked”, I wanted to give you the Cliffs Notes version here. This will be a two-part post; the first will deal with attack techniques and the second will describe appropriate design and implementation mitigations for the attacks.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The SOAP vs. REST debate has been raging (or at least simmering) for years now. While I don’t want to offer this blog as another battleground in this war, I do want to talk about some of the security issues affecting REST. Specifically, I want to talk about REST and its susceptibility to Cross-Site Request Forgery (XSRF) attacks.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Let’s look at a sample RESTful web service that provides information on movies and actors and TV shows – let’s call it BryMDB for Bryan’s Movie Database. If a user wanted to retrieve all of the available data for the movie Wanted, she would just make an HTTP GET request like this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;GET /movies/Wanted HTTP/1.1&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;If she noticed that no one had created an entry for the new James Bond movie and she wanted to add one, she would make a POST request with the movie data in the message body:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;POST /movies/Quantum_Of_Solace HTTP/1.1&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Similarly, the HTTP method POST is used to update existing data and DELETE is used to delete data. Essentially we have a mapping of data CRUD (Create/Read/Update/Delete) to HTTP methods POST, GET, PUT and DELETE. The problem with this is that unless preventative measures are taken, the service will be extremely vulnerable to XSRF attacks. For example, Evil Eve might write a page with the following HTML and JavaScript code:&lt;/FONT&gt;&lt;/P&gt;&lt;CODE&gt;&amp;lt;body onload=javascript:document.evil.submit()&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;lt;form name="evil" method="POST" action="http://www.brymdb.com/movies/Iron_Man" enctype="text/plain"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;input name="{review:'This movie is horrible! I want my money back!', rating:1}//" value=""/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/form&amp;gt;&lt;BR&gt;&amp;lt;/body&amp;gt;&lt;BR&gt;&lt;/CODE&gt;&lt;BR&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Now any visitor to this page will automatically post a negative review of Iron Man, whether they liked the movie or not (or even whether they’ve seen the movie or not)! And Eve doesn’t have to host this page on the brymdb.com domain. She can host this page anywhere and the attack will still be successful.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;In terms of REST, the “C” in CRUD as accessed through the POST method is actually the easiest to attack. However, R, U and D are all very much vulnerable as well. We’ll save “R” for last and focus on attacking update and delete functionality now.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;It’s more difficult for an attacker to forge PUT and DELETE requests since you can’t specify these methods as the “method” attribute of a &amp;lt;form&amp;gt; element – &amp;lt;form&amp;gt; only allows GET or POST. However, you can specify PUT or DELETE as the HTTP method used for XMLHttpRequest, like this:&lt;/FONT&gt;&lt;/P&gt;&lt;CODE&gt;var xhr = new XMLHttpRequest(); &lt;BR&gt;xhr.open("PUT", "http://www.brymdb.com/movies/Kung_Fu_Panda", true); &lt;BR&gt;xhr.send("{review:'This movie rocks!', rating:10}"); &lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The problem with this (if you’re an attacker) is that you can’t normally make cross-domain requests with XMLHttpRequest. There are two takeaways from this. The first is that this should really highlight the importance of preventing XSS in your applications. Once an attacker can add script of her choice to your pages, she can use XMLHttpRequest to send PUT and DELETE attacks against any REST services on the domain. (Actually at this point, attacks against your REST services are probably the least of your concerns.) The second takeaway is that this also shows the danger of the W3C cross-domain XHR proposal that I’ve previously written about &lt;A class="" href="http://blogs.msdn.com/bryansul/archive/2008/04/04/cross-domain-xhr-will-destroy-the-internet.aspx" mce_href="http://blogs.msdn.com/bryansul/archive/2008/04/04/cross-domain-xhr-will-destroy-the-internet.aspx"&gt;here&lt;/A&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;At this point, we’ve addressed means by which an attacker can attack POST, PUT, and DELETE methods, but we haven’t looked any ways to attack the most common HTTP method: GET. At first glance, attacking GET would seem trivial. There are literally dozens of ways to make browsers issue cross-domain GET requests. Here is a sampling of just a few of them:&lt;/FONT&gt;&lt;/P&gt;&lt;CODE&gt;&amp;lt;img src="http://www.brymdb.com/Movies/WallE"/&amp;gt; &lt;BR&gt;&lt;BR&gt;&amp;lt;iframe src="http://www.brymdb.com/Movies/WallE"&amp;gt; &lt;BR&gt;&lt;BR&gt;&amp;lt;object data="http://www.brymdb.com/Movies/WallE"&amp;gt; &lt;CODE&gt;&lt;BR&gt;&lt;BR&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The problem with this (again from the attacker’s perspective) is that in a true RESTful architecture, GET is only used to read or retrieve data. It does no good to issue forged GET requests if the attacker can’t read the (presumably valuable and confidential) data being returned from the server. You can’t use &amp;lt;img src&amp;gt; or any of the techniques listed above to read data. You can use XHR to issue GET requests and read the responses, but again, you can’t normally make cross-domain XHR requests.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;One possibility is to use a Rich Internet Application (RIA) to forge requests across domains. Both Flash and Silverlight allow you to issue cross-domain GET requests and read the responses, assuming that the target domain has an appropriate cross-domain access policy file in place. Silverlight code to perform a request forgery against a REST service would look like this:&lt;/FONT&gt;&lt;/P&gt;&lt;CODE&gt;void attack() { &lt;BR&gt;&amp;nbsp;&amp;nbsp;WebClient webClient = new WebClient(); &lt;BR&gt;&amp;nbsp;&amp;nbsp;webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(callback); &lt;BR&gt;&amp;nbsp;&amp;nbsp;webClient.DownloadStringAsync(new Uri("http://www.brymdb.com/Movies/WallE")); &lt;BR&gt;} &lt;BR&gt;&lt;BR&gt;void callback(object sender, DownloadStringCompletedEventArgs e) { &lt;BR&gt;&amp;nbsp;&amp;nbsp;string stolenData = e.Result; &lt;BR&gt;&amp;nbsp;&amp;nbsp;// now send it home… &lt;BR&gt;} &lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;For REST services that use JSONP as their response data format, you can also use script to redefine or “hijack” the JSONP callback function. Given this JSONP response body:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;myCallbackFunction("{review:'I loved it! It was much better than Cats.', rating:9}");&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;An exploit page would look like this:&lt;/FONT&gt;&lt;/P&gt;&lt;CODE&gt;&amp;lt;script type="text/javascript"&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;function myCallbackFunction(data) { &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var stolenReview = data.review; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var stolenRating = data.rating; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// send the stolen data home… &lt;BR&gt;&amp;nbsp;&amp;nbsp;} &lt;BR&gt;&amp;lt;/script&amp;gt; &lt;BR&gt;&amp;lt;script src="http://www.brymdb.com/Movies/WallE"/&amp;gt; &lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Notice the second &amp;lt;script&amp;gt; tag at the bottom of the page that calls the target REST service. We can use this trick since the service is returning JSONP, and JSONP is valid JavaScript. The cross-domain limitation we had with XHR and the RIAs does not apply here; you can use &amp;lt;script src&amp;gt; to call any domain on the internet, regardless of whether that domain has defined a cross-domain access policy.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;A variation of the JSONP hijacking attack shown above is to redefine the built-in JavaScript object constructor instead of the JSONP callback function. This attack will work on straight JSON as well as JSONP. However, most browsers (including IE) do not allow you to redefine the object constructor, which greatly reduces the potential pool of victims that could be affected by this attack.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Well, we’ve talked a lot about possible XSRF attack vectors against REST services. Next time, we’ll shatter the myth that XSRF is indefensible and present some mitigations for these attacks.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8870048" width="1" height="1"&gt;</content><author><name>bryansul</name><uri>http://blogs.msdn.com/members/bryansul.aspx</uri></author></entry><entry><title>Show some respect to XSS</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/bryansul/archive/2008/06/11/show-some-respect-to-xss.aspx" /><id>http://blogs.msdn.com/bryansul/archive/2008/06/11/show-some-respect-to-xss.aspx</id><published>2008-06-11T19:48:00Z</published><updated>2008-06-11T19:48:00Z</updated><content type="html">&lt;P&gt;StickyMinds.com has just posted an article of mine on the &lt;A class="" href="http://www.stickyminds.com/sitewide.asp?Function=WEEKLYCOLUMN&amp;amp;ObjectId=13773&amp;amp;ObjectType=ARTCOL&amp;amp;btntopic=artcol" mce_href="http://www.stickyminds.com/sitewide.asp?Function=WEEKLYCOLUMN&amp;amp;ObjectId=13773&amp;amp;ObjectType=ARTCOL&amp;amp;btntopic=artcol"&gt;dangers of XSS&lt;/A&gt;. (Although they still have my old bio from when I worked at HP, I'll have to get that changed!)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8591693" width="1" height="1"&gt;</content><author><name>bryansul</name><uri>http://blogs.msdn.com/members/bryansul.aspx</uri></author><category term="xss" scheme="http://blogs.msdn.com/bryansul/archive/tags/xss/default.aspx" /></entry><entry><title>SQL injection in classic ASP</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/bryansul/archive/2008/05/30/sql-injection-in-classic-asp.aspx" /><id>http://blogs.msdn.com/bryansul/archive/2008/05/30/sql-injection-in-classic-asp.aspx</id><published>2008-05-30T19:05:00Z</published><updated>2008-05-30T19:05:00Z</updated><content type="html">&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-bidi-theme-font: minor-bidi; mso-fareast-language: ZH-TW; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;In light of the recent wake of SQL injection attacks on&amp;nbsp;ASP sites, I'd like to highlight some&amp;nbsp;relevant&amp;nbsp;resources for learning about and&amp;nbsp;responding to&amp;nbsp;the threat.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-bidi-theme-font: minor-bidi; mso-fareast-language: ZH-TW; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;Bala Neerumalla has&amp;nbsp;written a detailed document for &lt;A class="" href="http://msdn.microsoft.com/en-us/library/cc676512.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc676512.aspx"&gt;preventing SQL injection in ASP&lt;/A&gt; (that is, classic ASP, not ASP.NET).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-bidi-theme-font: minor-bidi; mso-fareast-language: ZH-TW; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;The Security Vulnerability Research &amp;amp; Defense blog has posted an &lt;A class="" href="http://blogs.technet.com/swi/archive/2008/05/29/sql-injection-attack.aspx" mce_href="http://blogs.technet.com/swi/archive/2008/05/29/sql-injection-attack.aspx"&gt;analysis of the attack&lt;/A&gt;, along with guidance recommendations for IT/database admins, web developers, and end users.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-bidi-theme-font: minor-bidi; mso-fareast-language: ZH-TW; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;Finally, Michael Howard recently wrote a post on the SDL blog on&amp;nbsp;&lt;A class="" href="http://blogs.msdn.com/sdl/archive/2008/05/15/giving-sql-injection-the-respect-it-deserves.aspx" mce_href="http://blogs.msdn.com/sdl/archive/2008/05/15/giving-sql-injection-the-respect-it-deserves.aspx"&gt;SQL injection defenses&lt;/A&gt; required by the SDL.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-bidi-theme-font: minor-bidi; mso-fareast-language: ZH-TW; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8563585" width="1" height="1"&gt;</content><author><name>bryansul</name><uri>http://blogs.msdn.com/members/bryansul.aspx</uri></author><category term="sql injection" scheme="http://blogs.msdn.com/bryansul/archive/tags/sql+injection/default.aspx" /></entry><entry><title>Web Application Firewalls in Practice - or - Yes, Jeremiah, Secure Software Does Matter</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/bryansul/archive/2008/05/19/web-application-firewalls-in-practice-or-yes-jeremiah-secure-software-does-matter.aspx" /><id>http://blogs.msdn.com/bryansul/archive/2008/05/19/web-application-firewalls-in-practice-or-yes-jeremiah-secure-software-does-matter.aspx</id><published>2008-05-19T19:01:00Z</published><updated>2008-05-19T19:01:00Z</updated><content type="html">&amp;nbsp; 
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;There's been a lot of renewed interest in web application firewalls lately. In the past, I haven't been a huge fan of WAFs - they always seemed to me to be just a band-aid stuck on the sucking chest wound of insecure code. But I bumped into Jeremiah Grossman at &lt;A class="" href="http://www.microsoft.com/technet/security/bluehat/default.mspx" mce_href="http://www.microsoft.com/technet/security/bluehat/default.mspx"&gt;BlueHat&lt;/A&gt;, and he raised some &lt;A class="" href="http://jeremiahgrossman.blogspot.com/2008/05/does-secure-software-really-matter.html" mce_href="http://jeremiahgrossman.blogspot.com/2008/05/does-secure-software-really-matter.html"&gt;good points in defense of WAFs&lt;/A&gt;, the most compelling of which was the use of WAFs as emergency first-response tools. Consider the recent mass SQL injection attacks. Fixing these vulnerabilities is going to cost a lot of time and a lot of money. What if, instead of taking the vulnerable sites down while they're getting fixed (or worse, just leaving the sites up and vulnerable while they're getting fixed), the admins put WAFs in front of the sites to keep them up and running while the security holes get patched?&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;Now, I like this idea a lot. In theory. But in practice, what I'm afraid will happen is that the WAF will get put up as an emergency response, and then the actual code fixes will never get written because they'll take a long time and they'll cost a lot of money and why should we bother because we're already protected from the threat anyway? &lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;Maybe I'm being overly cynical about this. Right here, right now, I'm going to publicly change my stance on WAFs. WAFs can be an excellent defense-in-depth measure and a good emergency first-response tool, but they will never be a replacement for secure code or a secure software development lifecycle. Instead of a band-aid, think of a WAF as an all-star shortstop (or guard, or linebacker, depending on your sport of choice). He'll save you some runs, but you can't put him out on the field all by himself.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8519202" width="1" height="1"&gt;</content><author><name>bryansul</name><uri>http://blogs.msdn.com/members/bryansul.aspx</uri></author><category term="waf" scheme="http://blogs.msdn.com/bryansul/archive/tags/waf/default.aspx" /></entry><entry><title>Cross-domain XHR will destroy the internet</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/bryansul/archive/2008/04/04/cross-domain-xhr-will-destroy-the-internet.aspx" /><id>http://blogs.msdn.com/bryansul/archive/2008/04/04/cross-domain-xhr-will-destroy-the-internet.aspx</id><published>2008-04-04T23:23:00Z</published><updated>2008-04-04T23:23:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Ok, maybe “destroy the internet” is a little harsh. But let’s take a look the impact that implementation of the current &lt;/FONT&gt;&lt;A href="http://www.w3.org/TR/access-control/"&gt;&lt;FONT face=Calibri size=3&gt;W3C working draft for cross domain access&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; would have on browser security. Some people might argue that there’s no more risk from cross-domain XHR than there is from cross-domain Flash or Silverlight, but they would be wrong, for two reasons.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;First is a simple matter of increased attack surface. Flash and Silverlight support only the HTTP methods GET and POST. But attacks can be made with methods other than these, and XHR supports any arbitrary method. Attackers could send TRACE requests to probe for cross-site tracing vulnerabilities that defeat HttpOnly cookie protections. Or they could send PUT or DELETE requests to attack WebDAV sites or RESTful web services.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;In the second place, cross-domain XHR would increase the potential damage of a successful XSS. Arguably the worst, most damaging types of XSS attacks are the self-propagating XSS web worms. At Microsoft, any “wormable” vulnerability automatically gets our highest security bulletin rating. But for the most part, XSS web worms are confined to a single domain because of the constraints of the same origin policy. Now single-domain worms are bad enough – just ask &lt;/FONT&gt;&lt;A href="http://en.wikipedia.org/wiki/Samy"&gt;&lt;FONT face=Calibri size=3&gt;MySpace&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; – but cross-domain XHR would allow worms to spread across multiple domains, potentially infecting any site with both a stored XSS vulnerability and a permissive cross-domain policy.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Billy Hoffman and John Terrill presented some excellent material on &lt;/FONT&gt;&lt;A href="https://www.blackhat.com/presentations/bh-usa-07/Hoffman_and_Terrill/Whitepaper/bh-usa-07-hoffman_and_terrill-WP.pdf"&gt;&lt;FONT face=Calibri size=3&gt;cross-domain web worms&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; at Black Hat last year, but their approach relied on using blind GETs and POSTs to propagate across domains. An attack based on cross-domain XHR would not be limited in this way; the worm could read responses from the targets and vary its attacks accordingly. It could even include logic to defeat multiple-step submission processes like CAPTCHA checks.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;I know the cross-domain genie is out of the bottle now with pretty much every browser and RIA framework providing its own cross-domain request mechanism, but let’s try to kill this proposal and nip a future security nightmare in the bud. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;As an alternative to the W3C XHR proposal, I like IE8’s &lt;/FONT&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/cc288060(VS.85).aspx"&gt;&lt;FONT face=Calibri size=3&gt;XDomainRequest&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; (XDR). XDR only allows GET and POST requests, which is a good reduction in attack surface, but even better is the fact that XDR won’t ever send cookies. This is going to make exploitation of XSRF vulnerabilities via XDR impossible in most cases. Theoretically the web worm issue is still possible, but an attacker would have to find sites that:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;a.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Have persistent XSS vulnerabilities,&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;b.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Have permissive cross-domain policies, and&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;c.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Don’t use any kind of authentication or session cookies.&lt;/FONT&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA"&gt;Even assuming that any sites like this actually exist, the no-cookies restriction definitely limits the effectiveness of XDR as an attack vector compared to the W3C proposed standard.&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8358232" width="1" height="1"&gt;</content><author><name>bryansul</name><uri>http://blogs.msdn.com/members/bryansul.aspx</uri></author><category term="REST" scheme="http://blogs.msdn.com/bryansul/archive/tags/REST/default.aspx" /><category term="XHR" scheme="http://blogs.msdn.com/bryansul/archive/tags/XHR/default.aspx" /><category term="CSRF" scheme="http://blogs.msdn.com/bryansul/archive/tags/CSRF/default.aspx" /><category term="XMLHttpRequest" scheme="http://blogs.msdn.com/bryansul/archive/tags/XMLHttpRequest/default.aspx" /><category term="XSRF" scheme="http://blogs.msdn.com/bryansul/archive/tags/XSRF/default.aspx" /></entry><entry><title>BlueHat shows some love to web app security</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/bryansul/archive/2008/03/24/bluehat-shows-some-love-to-web-app-security.aspx" /><id>http://blogs.msdn.com/bryansul/archive/2008/03/24/bluehat-shows-some-love-to-web-app-security.aspx</id><published>2008-03-24T23:43:00Z</published><updated>2008-03-24T23:43:00Z</updated><content type="html">If you haven't heard yet, &lt;A class="" href="http://blogs.technet.com/bluehat/" mce_href="http://blogs.technet.com/bluehat/"&gt;BlueHat v7&lt;/A&gt; is dedicating the entire block of morning sessions to web app security issues. I'll be there, talking about my first 30 days as the new web app sec guy on the &lt;A class="" href="http://blogs.msdn.com/sdl/" mce_href="http://blogs.msdn.com/sdl/"&gt;SDL&lt;/A&gt; team. Hope to see you there!&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8334264" width="1" height="1"&gt;</content><author><name>bryansul</name><uri>http://blogs.msdn.com/members/bryansul.aspx</uri></author><category term="bluehat" scheme="http://blogs.msdn.com/bryansul/archive/tags/bluehat/default.aspx" /></entry></feed>