<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php" />
  <link rel="self" type="application/atom+xml" href="http://www.readwriteweb.com/atom.xml" />
  <id>tag:,2009:/1/tag:www.readwriteweb.com,2009://1.14702-</id>
  <updated>2009-11-23T17:01:46Z</updated>
  <title>Comments for Security Expert Suggests Twitter Focus on Output Escaping not Input Filtering</title>
  
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.23-en</generator>
  <entry>
    <id>tag:www.readwriteweb.com,2009://1.14702</id>
    <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php" />
    <link rel="service.edit" type="application/atom+xml" href="http://www.readwriteweb.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=1/entry_id=14702" title="Security Expert Suggests Twitter Focus on Output Escaping not Input Filtering" />
    <published>2009-04-18T23:38:24Z</published>
    <updated>2009-04-19T00:18:40Z</updated>
    <title>Security Expert Suggests Twitter Focus on Output Escaping not Input Filtering</title>
    <summary>Twitter&apos;s status blog this morning announced that Twitter has addressed the most recent variant of the Mikeyy worm but recommends that you still avoid viewing the profiles of users posting &quot;uncharacteristic or otherwise suspicious tweets.&quot; It shouldn&apos;t be this hard, Peter Soderling, founder of Stratus Security told ReadWriteWeb yesterday. &quot;It appears Twitter is solving the...</summary>
    <author>
      <name>Lidija Davis</name>
      
    </author>
    
    <category term="Web Security" />
    
    <content type="html" xml:lang="en" xml:base="http://www.readwriteweb.com/">
      <![CDATA[<p><img alt="filter_apr_09.jpg" src="http://www.readwriteweb.com/images/filter_apr_09.jpg" width="100" height="67" />Twitter's status <a href="http://status.twitter.com/post/97574654/progress-on-combating-ongoing-spam-attacks-on-twitter">blog</a> this morning announced that Twitter has addressed the most recent variant of the Mikeyy worm but recommends that you still avoid viewing the profiles of users posting "uncharacteristic or otherwise suspicious tweets."</p>

<p>It shouldn't be this hard, Peter Soderling, founder of <a href="http://www.stratusec.com/">Stratus Security</a> told ReadWriteWeb yesterday. "It appears Twitter is solving the problem by focusing on the input filtering, but a simpler and more effective solution would have been to focus on output escaping; encoding the script tags so they could not execute in any victim's browser."</p>]]>
      <![CDATA[<p>Web application development 101: You want to output something that the user has provided? Escape all of that data so that it is harmless.  But what does this really mean in plain English?</p>

<h2>Input Filtering in Plain English</h2>

<p>Input filtering is the way in which developers validate data coming into their applications, and thwart any invalid, incorrect or malicious data from being used or executed.  </p>

<p>Typically, when an application needs a user to input data, the site will offer a form, containing one or more fields.  </p>

<p>For instance, Twitter users have the ability to input data in a variety of places within their settings.  From the obvious - such as in the account tab -  where you can type in your name, username, e-mail, URL, bio, location etc., to the less obvious such as the 'change design colors' that allows you to enter data to specify color.</p>

<p>As a result, all of these fields need to be 'filtered' by the site - not just by making the input validation 'nice' for the user [as described below], but making it safe on the server.</p>

<p>From a user point of view, when you go to change the background color for example,  Twitter has ensured you can only input 6 hexadecimal characters; that is, the letters A through F and the digits 0 through 9.  </p>

<p>While this may provide users with a sense of relief that nothing malicious can be 'injected' into this field, it may also be providing a false sense of security if Twitter is not filtering the input on its servers.</p>

<p>Here's why.</p>

<p>When you hit the 'save changes' button after you have input your data, your browser sends that information to Twitter's server, which in turn will then store that information.</p>

<p>But what if the information Twitter's server receives tells it to do something malicious?  And, what if Twitter's server thinks that the information it has received was from the form where nothing 'bad' can be entered?  This is what Mikeyy did. "It basically let me do anything I want within a browser on their Web site," Michael Mooney, the worm's creator, told Andy Sorcini in an <a href="http://thedrilldown.com/2009/04/13/interview-with-twitter-stalkdaily-virus-author-mikeey/">interview</a> last week.</p>

<p>Think of it this way.  You're sending ReadWriteWeb a letter via snail mail.  The postman steams it open, rewrites it and delivers it to us.  The information we receive, while still appearing to come from you, may have nothing to do with the original information you sent us.</p>

<p>But how do you send information to Web apps without entering them in the specified fields?  Simple, if you have the tools.  Programs such as <a href="http://www.parosproxy.org/index.shtml">Paros</a>, a security tool created for Web application vulnerability assessment also allows those who are tech savvy enough to monitor, intercept and modify the data being sent to Twitter before it hits Twitter's server.  </p>

<p>Of course, this means Twitter is now storing information - not about a color, but potentially, instructions to do something malicious.</p>

<h2>Input Filtering at a Server Level</h2>

<p>When Twitter's server receives a request (such as to change the background color), it must validate that the information received corresponds to the values Twitter has assigned to it.  Continuing with the color example, it must validate that only hexadecimal data has been received.  </p>

<p>Clearly, Twitter did not do this from the get-go and is now furiously chasing input vulnerabilities that may be sprinkled in a variety of places within its code; patching them as it finds them; a long, painful and tedious process when done retrospectively.</p>

<p>Think of it this way.  A mouse is in your house.  You search to find the hole in the floor and you plug it.  Then you find another mouse.  Again, you search for the hole and plug it.  This can go on indefinitely.  However, had you, during the building stage, put down a concrete floor, there would be zero chance of mice living under your house, and fewer ways they could get in.</p>

<p>"Understanding why and where to filter is more important than understanding how," Chris Shiflett, CTO of <a href="http://omniti.com/">OmniTI</a> explains. "It's important to appreciate just how easily a form submission can be spoofed, so that you realize that absolutely nothing about the client's request can be blindly trusted."  He has written a good technical overview on <a href="http://shiflett.org/articles/input-filtering">input filtering</a> if you are interested in learning more.</p>

<h2>The Flip Side of the Coin: Output Escaping</h2>

<p>Output escaping, much like input filtering, is an additional precaution that developers can take when creating Web applications.</p>

<p>According to Soderling, it effectively renders any malicious code that is stored in a database useless.</p>

<p>Rather than focus on plugging holes in the input one by one, Soderling suggest Twitter focus on escaping outputs, which is easier from a developer point of view because it effectively requires only five steps to implement.  </p>

<p>So simple in fact, that PHP, a common programming language, has created <a href="http://us3.php.net/htmlspecialchars">htmlspecialchars</a> to automate this process in the PHP world.</p>

<p>"All Twitter needs to do is code the script tags so they cannot execute in any browser," Soderling explained.  "This particular type of attack is not entirely uncommon."  </p>

<p>And while it is likely that the majority of sites in the world are vulnerable, Twitter, with its team of capable developers should be better locked down.</p>

<p>However, Twitter is not alone in this.  <a href="http://devthought.com/">Guillermo Rauch</a> found a similar vulnerability in Digg today that he tested and quickly alerted Digg to (Digg has since fixed the bug).   You can read about the process <a href="http://devthought.com/blog/server-side/2009/04/the-digg-worm-that-wasnt/">here</a>. </p>

<p>Whether Twitter is dealing with this problem by focusing on input filtering or output escaping is still to be determined.  We've sent them an e-mail in an attempt to find out more and will update this post as soon as we hear back.</p>]]>
    </content>
  </entry>

  <entry>
    <id>tag:www.readwriteweb.com,2009://1.14702-comment:134240</id>
    <thr:in-reply-to ref="tag:www.readwriteweb.com,2009://1.14702" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php"/>
    <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php#c134240" />
    <title>Comment from Lucio Riccardi on 2009-04-18</title>
    <author>
        <name>Lucio Riccardi</name>
        <uri>http://friendfeed.com/cantorjf</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://friendfeed.com/cantorjf">
        <![CDATA[<p>Seems to me that all is into manuals and best pratices .. and it's kind impossibe to imagine how twitter can suffer of this kind of sickness. How many imput /output has twitter? And on web? Less then all the Social Network i know, and for 4 times we see Mickeyy attacks .. i start to belive in Scoble about Twitter ..</p>]]>
    </content>
    <published>2009-04-19T00:53:01Z</published>
  </entry>

  <entry>
    <id>tag:www.readwriteweb.com,2009://1.14702-comment:134238</id>
    <thr:in-reply-to ref="tag:www.readwriteweb.com,2009://1.14702" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php"/>
    <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php#c134238" />
    <title>Comment from Pete Nicholls on 2009-04-18</title>
    <author>
        <name>Pete Nicholls</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>I think that the problem with output escaping is to do with the disparate nature that Twitter clients take to rendering escaped entities properly. Some clients do it well, others do little or nothing at all to render them properly.</p>

<p>If you start encoding all the character entities in the output, you could potentially break clients and services that rely on Twitter working as it does at the moment.</p>]]>
    </content>
    <published>2009-04-19T01:00:55Z</published>
  </entry>

  <entry>
    <id>tag:www.readwriteweb.com,2009://1.14702-comment:134241</id>
    <thr:in-reply-to ref="tag:www.readwriteweb.com,2009://1.14702" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php"/>
    <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php#c134241" />
    <title>Comment from Will Anderson on 2009-04-18</title>
    <author>
        <name>Will Anderson</name>
        <uri>http://www.itsananderson.com/</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.itsananderson.com/">
        <![CDATA[<p>While that's a valid concern, I think the security issues outweigh the potential client bugs that could arise. Twitter could avoid 99% of security vulnerabilities by just escaping angle brackets and maybe ampersands (&). That would be something that could quickly be worked into most clients.</p>

<p>Another option would be to deliver escaped content to the web interface, but send the unescaped content to other clients, making them responsible for any escaping that needs to be done.</p>]]>
    </content>
    <published>2009-04-19T01:20:00Z</published>
  </entry>

  <entry>
    <id>tag:www.readwriteweb.com,2009://1.14702-comment:134246</id>
    <thr:in-reply-to ref="tag:www.readwriteweb.com,2009://1.14702" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php"/>
    <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php#c134246" />
    <title>Comment from Windows Service Pack on 2009-04-18</title>
    <author>
        <name>Windows Service Pack</name>
        <uri>http://windows-service-pack.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://windows-service-pack.com">
        <![CDATA[<p>I think that their may be problem of output escaping is to do with the disparate nature that Twitter clients make some rendering escaped entities properly and to be valid.<br />
</p>]]>
    </content>
    <published>2009-04-19T02:58:06Z</published>
  </entry>

  <entry>
    <id>tag:www.readwriteweb.com,2009://1.14702-comment:134256</id>
    <thr:in-reply-to ref="tag:www.readwriteweb.com,2009://1.14702" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php"/>
    <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php#c134256" />
    <title>Comment from 布里斯班 on 2009-04-18</title>
    <author>
        <name>布里斯班</name>
        <uri>http://brisbane.at9t.com/</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://brisbane.at9t.com/">
        <![CDATA[<p>Without any doubt, it's always more important to control the output data.</p>]]>
    </content>
    <published>2009-04-19T05:30:55Z</published>
  </entry>

  <entry>
    <id>tag:www.readwriteweb.com,2009://1.14702-comment:134258</id>
    <thr:in-reply-to ref="tag:www.readwriteweb.com,2009://1.14702" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php"/>
    <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php#c134258" />
    <title>Comment from Elpie on 2009-04-18</title>
    <author>
        <name>Elpie</name>
        <uri>http://lynnepope.net</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://lynnepope.net">
        <![CDATA[<p>Their security efforts might also be helped if they updated the JavaScript libraries they are using. Twitter is not keeping up to date with its JQuery and is still using a beta of the Sizzle CSS selector engine.<br />
While neither of these libraries have known vulnerabilities both have been improved in versions later than the ones Twitter is using. </p>]]>
    </content>
    <published>2009-04-19T06:36:25Z</published>
  </entry>

  <entry>
    <id>tag:www.readwriteweb.com,2009://1.14702-comment:134260</id>
    <thr:in-reply-to ref="tag:www.readwriteweb.com,2009://1.14702" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php"/>
    <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php#c134260" />
    <title>Comment from Khurram on 2009-04-18</title>
    <author>
        <name>Khurram</name>
        <uri>http://www.spryka.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.spryka.com">
        <![CDATA[<p>Twitter is like a breath of fresh air on the Social Media scene. I have been on it for just a few weeks now and I have met several interesting people. It is a platform to network with people you would like to meet in real life. Check me out!!</p>

<p><a href="http://twitter.com/spryka" rel="nofollow"> <a href="http://twitter.com/spryka" rel="nofollow">http://twitter.com/spryka</a> </a></p>]]>
    </content>
    <published>2009-04-19T06:57:45Z</published>
  </entry>

  <entry>
    <id>tag:www.readwriteweb.com,2009://1.14702-comment:134293</id>
    <thr:in-reply-to ref="tag:www.readwriteweb.com,2009://1.14702" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php"/>
    <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php#c134293" />
    <title>Comment from Residual Income For You on 2009-04-19</title>
    <author>
        <name>Residual Income For You</name>
        <uri>http://www.residual-income-4-u.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.residual-income-4-u.com">
        <![CDATA[<p>Follow the experts, they know what they are talking about. </p>]]>
    </content>
    <published>2009-04-19T13:25:48Z</published>
  </entry>

  <entry>
    <id>tag:www.readwriteweb.com,2009://1.14702-comment:134332</id>
    <thr:in-reply-to ref="tag:www.readwriteweb.com,2009://1.14702" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php"/>
    <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php#c134332" />
    <title>Comment from Mehmet Yanki YONEL on 2009-04-19</title>
    <author>
        <name>Mehmet Yanki YONEL</name>
        <uri>http://www.myproduksiyon.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.myproduksiyon.com">
        <![CDATA[<p>Thank you for the usefull article.</p>]]>
    </content>
    <published>2009-04-19T19:07:02Z</published>
  </entry>

  <entry>
    <id>tag:www.readwriteweb.com,2009://1.14702-comment:134373</id>
    <thr:in-reply-to ref="tag:www.readwriteweb.com,2009://1.14702" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php"/>
    <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php#c134373" />
    <title>Comment from l.m.orchard on 2009-04-19</title>
    <author>
        <name>l.m.orchard</name>
        <uri>http://decafbad.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://decafbad.com">
        <![CDATA[<p>@Pete Nicholls: That's not a problem with output escaping, that's a problem with the clients.  The rules of encoding content for HTML/XML/JSON are not new - and it's not Twitter's job to invent formats inspired by HTML/XML/JSON that sorta-but-not-really-encode.  </p>

<p>Breaking those clients would be doing them a favor by surfacing bugs and mistaken assumptions that might bite them in the future anyway.</p>]]>
    </content>
    <published>2009-04-20T01:19:52Z</published>
  </entry>

  <entry>
    <id>tag:www.readwriteweb.com,2009://1.14702-comment:136459</id>
    <thr:in-reply-to ref="tag:www.readwriteweb.com,2009://1.14702" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php"/>
    <link rel="alternate" type="text/html" href="http://www.readwriteweb.com/archives/security_expert_suggests_twitter_focus_on_output_e.php#c136459" />
    <title>Comment from mikuss on 2009-05-04</title>
    <author>
        <name>mikuss</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>"We've sent them an e-mail in an attempt to find out more and will update this post as soon as we hear back."</p>

<p>Hopefully nobody intercepted this clear text email and inserted malicious code...</p>

<p>Yuk Yuk Yuk!!<br />
</p>]]>
    </content>
    <published>2009-05-04T14:18:49Z</published>
  </entry>

</feed>