<?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: dwr]]></title>
    <link>http://securityratty.com/tag/dwr</link>
    <description></description>
    <pubDate>Tue, 24 Jun 2008 15:09:34 +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>
    <item>
      <title><![CDATA[Minimizing the Attack Surface, Part 1]]></title>
      <link>http://securityratty.com/article/4cc07bb9b410d28285eec3f2156fa1e6</link>
      <guid>http://securityratty.com/article/4cc07bb9b410d28285eec3f2156fa1e6</guid>
      <description><![CDATA[What was the first thing you learned about network security? Theres a good chance it had something to do with port scanning. After scanning a few boxes, you realized that modern operating systems have...]]></description>
      <content:encoded><![CDATA[<p>What was the first thing you learned about network security?  There&#8217;s a good chance it had something to do with port scanning.  After scanning a few boxes, you realized that modern operating systems have a lot of open ports by default, meaning a lot of services.  Some had an obvious purpose, like telnet on tcp/23 or ftp fon tcp/21.  Others left you wondering, what the heck is listening on tcp/515 or tcp/7100?  And remember, you couldn&#8217;t ask Google because it didn&#8217;t exist (well, maybe it did depending on when you got into security).</p>
<p>Your first real lesson about locking down a host was how to reduce its attack surface.  You learned how to disable services using /etc/inetd.conf.  Then you learned about rc.d and how to prevent unnecessary services from being launched at startup.  Next, maybe you configured the Xserver to disallow remote connections or moved on to removing setuid permissions from files.  As you worked, you&#8217;d periodically re-scan the box to gauge progress, asking yourself &#8220;have I removed everything I don&#8217;t need?&#8221;  The underlying motivation, of course, is that an attacker can&#8217;t hack something that isn&#8217;t there.</p>
<p>You learned how to extend those concepts to the network &#8212; configuring firewall rules, router ACLs, VLANs, etc.  Segmenting the network.  Creating a DMZ.  No need to dwell on this, you get the idea.</p>
<p>Eventually, people realized that applications had an attack surface too.  Web servers and application servers got a lot of attention, followed closely by custom web applications.  &#8220;What do you mean you can execute SQL queries against my database?  That&#8217;s impossible, I have a firewall!&#8221;</p>
<p>Some companies, the ones who could afford it anyway, started to build security into their development cycle.  Doing threat modeling during the design phase made sense, because hey, it&#8217;s much cheaper to fix security holes in a whiteboard drawing than it is to rewrite your authorization module from scratch after it&#8217;s in production.</p>
<p>Let&#8217;s talk strictly about custom web applications now.  What I&#8217;ve observed is that most development groups, even the ones who actively engage in threat modeling, do not understand their web application&#8217;s attack surface.  The lead architect can whiteboard a high-level diagram of all the major components and how they interact.  Individual developers can go a bit deeper, telling you which files they touch, what database permissions they need, or how various pieces of data are encrypted in storage.  At the end of this exercise you have a complete picture of the processes, data flows, protocols, privilege boundaries, external entities, and so on, and you&#8217;re well on your way to understanding all of the potential attack vectors.</p>
<p>Or are you?</p>
<p>What often gets overlooked or glossed over is the impact of external libraries or packages.  Nobody writes everything from scratch. A typical list of third-party libraries for a Java-based Web 2.0 application might include DWR, GWT, Axis, and Dojo, plus about 30 other libraries to do everything from logging to parsing to image manipulation.  Nine out of ten times, the libraries will be installed in full, using the default configuration from page one of the README file.</p>
<p>Why is this relevant? Because just as those old Unix boxes exposed unnecessary services, libraries expose unnecessary code.  Let&#8217;s say you installed Dojo to simplify the process of creating an HTML table with rows and columns that can be sorted on demand.  Did you remember to remove all the .js files you didn&#8217;t need?  Or maybe you installed Axis or DWR or anything else that has its own Servlet(s) for processing requests.  Have you compared what that Servlet <i>can do</i> against what you <i>need it to do</i>?  </p>
<p>A fictitious example may help illustrate further.  Imagine you just downloaded a new library called WhizBang.  You follow the installation instructions to define and map two servlets in your web.xml file, WhizServlet and BangServlet, and you configure it to integrate with your web app.  After a bit of trial and error, it&#8217;s functional. Yay!  This is where most developers stop.  </p>
<p>Nobody asks, &#8220;how much of this do I actually need?&#8221;  Case in point, what if your application only uses WhizServlet?  BangServlet is still exposed, and you don&#8217;t even use it!  Similarly, what if WhizServlet takes an &#8220;action&#8221; parameter which can be either &#8220;view&#8221;, &#8220;edit&#8221;, or &#8220;delete&#8221;, and your application only uses &#8220;view&#8221;?  You&#8217;re still exposing the other actions to anybody who knows the URL syntax (pretty trivial if it&#8217;s open source).  You wouldn&#8217;t expose large chunks of your own code that you weren&#8217;t using, so why should it be any different with libraries?</p>
<p>This post is getting kind of long so I&#8217;m going to split it up.  In the next post, I&#8217;ll continue the discussion of attack surface minimization, as well as some of the tradeoffs that go along with this approach.</p>
]]></content:encoded>
      <pubDate>Tue, 24 Jun 2008 15:09:34 +0000</pubDate>
      <category domain="http://securityratty.com/tag/attack surface">attack surface</category>
      <category domain="http://securityratty.com/tag/custom web applications">custom web applications</category>
      <category domain="http://securityratty.com/tag/web">web</category>
      <category domain="http://securityratty.com/tag/services">services</category>
      <category domain="http://securityratty.com/tag/prevent unnecessary services">prevent unnecessary services</category>
      <category domain="http://securityratty.com/tag/unnecessary services">unnecessary services</category>
      <category domain="http://securityratty.com/tag/security">security</category>
      <category domain="http://securityratty.com/tag/third-party libraries">third-party libraries</category>
      <category domain="http://securityratty.com/tag/fix security holes">fix security holes</category>
      <source url="http://www.veracode.com/blog/?p=111">Minimizing the Attack Surface, Part 1</source>
    </item>
  </channel>
</rss>
