<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
  <channel>
    <title><![CDATA[[SecurityRatty] tag: dwrs]]></title>
    <link>http://securityratty.com/tag/dwrs</link>
    <description></description>
    <pubDate>Sun, 29 Jun 2008 23:04:21 +0000</pubDate>
    <generator>iRatty Engine</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <item>
      <title><![CDATA[Minimizing the Attack Surface, Part 2]]></title>
      <link>http://securityratty.com/article/acfca889e523dfb012c5b7b6ad84ac5f</link>
      <guid>http://securityratty.com/article/acfca889e523dfb012c5b7b6ad84ac5f</guid>
      <description><![CDATA[Im finally getting around to finishing my post on minimizing attack surfaces. Heres Part 1 , in case you missed it
First, a quick clarification. I noticed that some of the readers who commented on...]]></description>
      <content:encoded><![CDATA[<p>I&#8217;m finally getting around to finishing my post on minimizing attack surfaces.  Here&#8217;s <a href="http://www.veracode.com/blog/?p=111">Part 1</a>, in case you missed it.</p>
<p>First, a quick clarification.  I noticed that some of the readers who commented on that first post wanted to talk about improving security through the use of various development methodologies or coding frameworks.  Those are interesting tangents (and ones that I may write about in the future), but my intention with this post is to discuss a very specific problem related to how people integrate third-party code &#8212; that is, the stuff you import or link in but didn&#8217;t write yourself.  </p>
<p>As I mentioned previously, developers have a tendency to &#8220;bolt on&#8221; third-party components to applications without understanding the security implications.  Often, these components are glossed over or ignored completely during threat modeling discussions.  I attempted to illustrate this with my fictitious WhizBang library example in Part 1.</p>
<p>When integrating a third-party component, developers familiarize themselves with the API but generally don&#8217;t care how it&#8217;s implemented.  Granted, that&#8217;s how an API is supposed to work; you don&#8217;t have to futz around with code beyond the API boundary, and you can blissfully ignore parts of the library that you don&#8217;t need.  In past consulting gigs, I&#8217;ve sat in threat modeling discussions where nobody knew whether a particular library generated network traffic.  &#8220;We just use the API,&#8221; they say.  The fact that it works is good enough; nobody seems to care <i>how</i> it works.</p>
<p>That mindset is ideal for rapid development but problematic for security.  Failing to understand the complete application, as opposed to just the part you wrote, prevents you from accurately assessing its security posture.</p>
<p>It&#8217;s also no coincidence that web app pen testers love third-party components &#8212; we get excited when we see &#8220;bolted on&#8221; interfaces, because we know that developers tend to leave extraneous functionality exposed.  The resulting findings usually generate reactions such as &#8220;I didn&#8217;t even know that servlet had an upload function.&#8221;</p>
<p><b>An Example</b></p>
<p>Here&#8217;s a close-to-home example related to my post about <a href="http://www.veracode.com/blog/?p=115">DWR 2.0.5</a> from the other day.  DWR is an Ajax framework that has a variety of operating modes.  In-house, we use a subset of DWR&#8217;s full functionality &#8212; specifically, we interact with it using the &#8220;plaincall&#8221; method only, so we made sure that the features we didn&#8217;t need were disabled via the configuration file.  As it turned out, there were vulnerable code paths prior to the &#8220;do you have this thing disabled&#8221; check.  In hindsight, if we had taken more time to understand the exposed interfaces, we could have reduced the attack surface by filtering out unneeded request patterns before they even touched the third-party code.</p>
<p>But wait, you say.  What about maintainability?  If I whitelist using a point-in-time application profile, doesn&#8217;t this create the same maintenance headache as the reviled WAF?  It doesn&#8217;t have to.  Certainly, one option would be to whitelist each and every unique URL that references the DWR framework, e.g.</p>
<pre>
/dwr/call/plaincall/myMethod1
/dwr/call/plaincall/myMethod2
/dwr/call/plaincall/myMethod3
</pre>
<p>But then you&#8217;d have to update the whitelist every time you added or removed functionality from your application.  Also, don&#8217;t lose sight of the security goal, which is to minimize the amount of exposed third-party code.  If I add or remove URLs that list, provided they are still using the &#8220;plaincall&#8221; method, I&#8217;m hitting the same DWR dispatcher every time.  So I&#8217;ve increased maintenance cost without any security benefit.  </p>
<p>A better option is to simply tighten the URL pattern a bit in the J2EE container.  Here&#8217;s the default configuration:</p>
<pre>
&lt;servlet-mapping&gt;
  &lt;servlet-name&gt;dwr-invoker&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/dwr/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
</pre>
<p>Now, instead of allowing every URL starting with <code>/dwr/</code> to be processed by the DWR library, you could be a little more restrictive:</p>
<pre>
&lt;servlet-mapping&gt;
  &lt;servlet-name&gt;dwr-invoker&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/dwr/call/plaincall/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
</pre>
<p>In this configuration, you don&#8217;t have to worry about <code>/dwr/call/someothercodepath</code> any more.  There is less third-party code exposed, thereby reducing the overall attack surface of the application.  (NB: DWR also serves up a couple of Javascript files, so those URL patterns will have to be whitelisted too)</p>
<p><b>A Logical Extension</b></p>
<p>Even if you&#8217;re not a developer, you should still be thinking about attack surfaces.  People download and install blogging platforms such as WordPress, Movable Type, etc. all the time, but how many take <a href="http://blogsecurity.net/wordpress/wordpress-security-whitepaper/">additional steps</a> to harden their installations?  The concept is the same as the OS hardening analogy I brought up at the very beginning of this discussion.</p>
<p>Similarly, people install third-party <a href="http://milw0rm.com/search.php?dong=wordpress+plugin">WordPress plugins</a> or <a href="http://milw0rm.com/search.php?dong=joomla+component">Joomla components</a> without considering that most of them are written by some random programmer who is a whiz with the plugin API but knows nothing about security?  </p>
<p>At the risk of sounding trite, always remember that security is <a href="http://www.schneier.com/blog/archives/2005/12/weakest_link_se.html">only as strong as the weakest link</a>.</p>
]]></content:encoded>
      <pubDate>Mon, 07 Jul 2008 17:10:25 +0000</pubDate>
      <category domain="http://securityratty.com/tag/dwr-invoker dwr">dwr-invoker dwr</category>
      <category domain="http://securityratty.com/tag/dwr-invoker">dwr-invoker</category>
      <category domain="http://securityratty.com/tag/dwr library">dwr library</category>
      <category domain="http://securityratty.com/tag/dwr">dwr</category>
      <category domain="http://securityratty.com/tag/library">library</category>
      <category domain="http://securityratty.com/tag/security">security</category>
      <category domain="http://securityratty.com/tag/dwr dispatcher">dwr dispatcher</category>
      <category domain="http://securityratty.com/tag/security posture">security posture</category>
      <category domain="http://securityratty.com/tag/point-in-time application profile">point-in-time application profile</category>
      <source url="http://www.veracode.com/blog/?p=113">Minimizing the Attack Surface, Part 2</source>
    </item>
    <item>
      <title><![CDATA[DWR 2.0.5 Fixes XSS Vulnerability]]></title>
      <link>http://securityratty.com/article/17edeff537933523a97f80fd17675a5d</link>
      <guid>http://securityratty.com/article/17edeff537933523a97f80fd17675a5d</guid>
      <description><![CDATA[DWR 2.0.5 addresses an XSS vulnerability that is likely to be exploitable in most 2.0.4 installations. If your web application uses DWRs Ajax implementation, download and install this update now
As an...]]></description>
      <content:encoded><![CDATA[<p><a href="http://directwebremoting.org/dwr/download">DWR 2.0.5</a> addresses an XSS vulnerability that is likely to be exploitable in most 2.0.4 installations.  If your web application uses DWR&#8217;s Ajax implementation, download and install this update now!</p>
<p>As an aside, I&#8217;ve been a fan of DWR for a while now, not only because of its ease of integration but also because it was the first Ajax framework to offer built-in CSRF protection.  You could tell that <a href="http://getahead.org/blog/joe/">Joe Walker</a> was taking security seriously.  For this particular vulnerability, I e-mailed him on a Saturday night, and within 12 hours, he had confirmed the problem, patched the code, and built a 2.0.5 release candidate.  Granted, it was a tiny code change, but I&#8217;ve still never seen a response that fast.  Less than a week later, the official 2.0.5 release (which incorporated a couple other fixes) was ready for download.</p>
<p>That&#8217;s it for now, but I&#8217;ll be referencing this example again when I get around to writing Part 2 of my <a href="http://www.veracode.com/blog/?p=111">Minimizing the Attack Surface</a> post.</p>
]]></content:encoded>
      <pubDate>Sun, 29 Jun 2008 23:04:21 +0000</pubDate>
      <category domain="http://securityratty.com/tag/vulnerability">vulnerability</category>
      <category domain="http://securityratty.com/tag/xss vulnerability">xss vulnerability</category>
      <category domain="http://securityratty.com/tag/code">code</category>
      <category domain="http://securityratty.com/tag/dwr">dwr</category>
      <category domain="http://securityratty.com/tag/tiny code change">tiny code change</category>
      <category domain="http://securityratty.com/tag/attack surface post">attack surface post</category>
      <category domain="http://securityratty.com/tag/dwrs ajax implementation">dwrs ajax implementation</category>
      <category domain="http://securityratty.com/tag/ajax framework">ajax framework</category>
      <category domain="http://securityratty.com/tag/saturday night">saturday night</category>
      <source url="http://www.veracode.com/blog/?p=115">DWR 2.0.5 Fixes XSS Vulnerability</source>
    </item>
  </channel>
</rss>
