<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Guillermo Rauch&#039;s Devthought &#187; security</title>
	<atom:link href="http://www.devthought.com/tag/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devthought.com</link>
	<description></description>
	<lastBuildDate>Mon, 30 Jan 2012 16:38:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>On the subject of login forms security</title>
		<link>http://www.devthought.com/2009/09/05/on-the-subject-of-login-forms-security/</link>
		<comments>http://www.devthought.com/2009/09/05/on-the-subject-of-login-forms-security/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 05:14:26 +0000</pubDate>
		<dc:creator>Guillermo Rauch</dc:creator>
				<category><![CDATA[Server side]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://devthought.com/?p=523</guid>
		<description><![CDATA[This post has a twofold goal. Make users aware of the implications of non-secure login forms is one. The other and most important one, given the nature of this blog&#8217;s audience, is make website makers and webmasters aware of this &#8230; <a href="http://www.devthought.com/2009/09/05/on-the-subject-of-login-forms-security/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This post has a twofold goal. Make users aware of the implications of non-secure login forms is one. The other and most important one, given the nature of this blog&#8217;s audience, is make website makers and webmasters aware of this problem, and how easy they can solve it.</p>
<p>I&#8217;ll also examine the alternative of implementing OpenID as the sole login provider of a website, and how it becomes the most suitable option for the majority of scenarios today.</p>
<p><span id="more-523"></span></p>
<h3>An introduction</h3>
<p>In this article we&#8217;ll consider a login form or website <em>non-secure</em> when sensitive data (for example, but not limited to, emails, passwords, private messages, credit cards information) is transmitted across a digital network without a strong encryption mechanism in place. In the majority of cases, this means transmitting data from one end to the other in <a href="http://en.wikipedia.org/wiki/Plaintext">Plaintext</a>, using the HTTP protocol instead of HTTPS.</p>
<h3>A reality check: for users</h3>
<p>One of the first concerns for <em>users</em> of non-secure websites should be network sniffing. With an utility such as <a href="http://wireshark.com">Wireshark</a> (formerly known as ethereal), an attacker can easily intercept and read packages that contain plaintext data.</p>
<p>This could be anything from chat conversations, or that password you&#8217;re sending to a non-SSL site. When you sign up for a website that doesn&#8217;t implement <em>https</em> remember to use a new, unique and discardable password. Never use the same password more than once!</p>
<h3>A reality check: for webmasters</h3>
<p>With open wireless telecommunication becoming more popular every day, network eavesdropping gets easier and more appealing for attackers. Websites that do not protect their users data will become easy targets for electronic identity theft and other opportunistic crimes.</p>
<p>Most login forms we find today offer no SSL support for sensitive data transmissions. Just browse to your favorite startup or Twitter mashup to see how much they protect your information. Even extremely popular websites such as <a href="http://digg.com/login/">Digg</a>, <a href="http://slashdot.org">Slashdot</a>, <a href="http://stumbleupon.com">StumbleUpon</a>, <a href="http://www.hi5.com/friend/login.do">Hi5</a>, <a href="http://www.reddit.com/login?dest=%2F">Reddit</a>, <a href="http://justin.tv">Justin.TV</a>, <a href="http://www.washingtonpost.com/">Washington Post</a>, <a href="http://members.forbes.com/membership/editprofile.do">Forbes</a>, <a href="http://xanga.com">Xanga</a> fail to protect your authentication information.</p>
<p>All it takes to fix your login forms is to add support for the HTTPS protocol to your web server of choice. Most popular web hosting providers already support it, yet few people take advantage of it.</p>
<p>One of the reasons people are reluctant to build-in SSL is the requirement of a certificate signed by a trusted authority. But it&#8217;s a really <a href="https://www.godaddy.com/gdshop/ssl/ssl.asp">small</a> price, that pays back with a lot of benefits for your organization.</p>
<h3>The JavaScript alternative</h3>
<p>You can make your non-secure forms a little more secure by creating a <a href="http://pajhome.org.uk/crypt/md5/sha1src.html">SHA1</a> hash before the form is sent, instead of sending the plaintext password.</p>
<p>However, this technique, which is implemented by <a href="http://vbulletin.com">vBulletin</a> for example, has its downsides:</p>
<ul>
<li>Only makes it more secure for Javascript-enabled user agents</li>
<li>It&#8217;s not an encryption method, so it&#8217;ll only be useful for login forms, and not for emails, private messages, credit cards, etc</li>
</ul>
<h3>The OpenID Alternative</h3>
<p>The <em>OpenID Authentication 2.0</em> specification takes into consideration the security threats described previously, and the suggested solution is evident:</p>
<blockquote class="quotebox"><div>While the protocol does not require SSL be used, its use is strongly RECOMMENDED.  Current best practices dictate that an OP SHOULD use SSL, with a certificate signed by a trusted authority, to secure its Endpoint URL as well as the interactions with the end user&#8217;s User-Agent.</div>
</blockquote>
<p>While it&#8217;s clear that SSL is optional in the authentication transactions, the following sentence is of interest to us:</p>
<blockquote class="quotebox"><div>Following its own security policies, a Relying Party MAY choose to not complete, or even begin, a transaction if SSL is not being correctly used at these various endpoints.</div>
</blockquote>
<p>If OpenID is implemented, it&#8217;s almost guaranteed for the website owner that the user&#8217;s login information will be protected. The main reason is that the majority of <em>popular</em> OpenID providers respect the security considerations listed in the specification. The attacker can still intercept authentication data if you don&#8217;t have SSL in the callback page that OpenId forwards the user to, but all he could potentially get is a random token and not the password itself.</p>
<h3>Conclusion</h3>
<p>The potential security issues of websites form authentication are varied, and encryption is only a tiny part of the solution. Securing users login should be one of the top priorities in web makers agendas. People value the data and history they&#8217;ve created in the websites they like, and it can be pretty disappointing to lose it all because the creator decided it was worth investing more time in refining the website&#8217;s gradient backgrounds rather than implementing SSL.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devthought.com/2009/09/05/on-the-subject-of-login-forms-security/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Digg worm that wasn&#039;t</title>
		<link>http://www.devthought.com/2009/04/18/the-digg-worm-that-wasnt/</link>
		<comments>http://www.devthought.com/2009/04/18/the-digg-worm-that-wasnt/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 16:55:16 +0000</pubDate>
		<dc:creator>Guillermo Rauch</dc:creator>
				<category><![CDATA[Server side]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://devthought.com/?p=827</guid>
		<description><![CDATA[Two nights ago I was editing my Digg profile and couldn&#8217;t help but think about the recent Mikeyy and Twitter revolt. Within minutes I had found a XSS exploit that could theoretically allow me to achieve the same. Half an &#8230; <a href="http://www.devthought.com/2009/04/18/the-digg-worm-that-wasnt/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Two nights ago I was editing my Digg profile and couldn&#8217;t help but think about the recent Mikeyy and Twitter revolt. Within minutes I had found a XSS exploit that could theoretically allow me to achieve the same.</p>
<p>Half an hour later, I had a working worm ready to infect everyone that saw my profile page, which also would propagate to theirs.</p>
<p><span id="more-827"></span></p>
<h3>Locating the vulnerability</h3>
<p>XSS vulnerabilities are quite ironic nowadays. Everyone knows about them, almost everyone knows what their most frequent form is, but few seem to test for them or implement systems to avoid them.</p>
<p>The most common form of a XSS exploit scenario is that in which the attacker manages to store malicious code in the host, which when shown is not escaped properly and is thus executed. On Digg, all it took me was to insert a <code class="inline">&lt;script&gt;</code> tag in the &#8220;About me&#8221; textarea.</p>
<p>Less known forms of XSS exploits involve other pathways through which the user sends information:</p>
<ul>
<li><strong>Request headers</strong>. A malicious user, like Al Capone or Mikeyy, could alter the <em>User Agent</em> or <em>Referer</em>, for example, to store malicious code. </li>
<li><strong>Query string</strong>. Commonly known as the PHP_SELF bug, the vulnerable sites are those which print out the request URL without escaping it. For example, if a programmer decides to populate the a <code class="inline">&lt;form action=""&gt;</code> with the unsanitized request URL, an attacker could inject code that can be conveniently distributed with URL shortening services.</li>
</ul>
<p>It&#8217;s also important to remember that preventing XSS exploits is not about escaping <code class="inline">&lt;</code> or <code class="inline">&gt;</code> alone. I recommend checking out <a href="http://ha.ckers.org/xss.html">this cheatsheet</a> for a comprehensive list of possible, real-world attacks.</p>
<h3>Exploiting it</h3>
<p>The exploit code is only anecdotally interesting. I do not encourage anyone to start testing random websites and injecting harmful JavaScript.</p>
<p>The attack plan is as follows</p>
<ol>
<li>
<p>Check the user is logged in, by checking for the absence of a login link.</p>
<pre class='highlight ' lang="javascript">
if ($('#header-login').attr('href')) return;
	</pre>
</li>
<li>
<p>Propagate the script by retrieving the profile edit details form and ajaxly submitting it.</p>
<pre class='highlight ' lang="javascript">
$.ajax({url: 'http://digg.com/settings/about', dataType: 'html', success: function(doc){
	// ...
	$.ajax({url: 'http://digg.com/settings/about', data: form.serialize(), type: 'POST'});
	// ...
}});
	</pre>
</li>
<li>We disable the Digg Bar by posting to http://digg.com/settings/viewing. This time we don&#8217;t really need to retrieve the whole form, because we already have the magic token that prevents CSRF attacks</li>
<li>We shout to friends to check out our profile. When a friend is infected, the <code class="inline">&lt;script&gt;</code> tag also holds the information of the scripter, so that the victim doesn&#8217;t shout back, which could raise suspicions that something fishy is going on.</li>
<li>
<p>We also store the created shouts ids in a cookie, to hide them from the user view as soon as the script loads and avoid users seeing weird shouts they didn&#8217;t voluntarily send.</p>
<pre class='highlight ' lang="javascript">
var shouts = $.cookie('shouts'), shoutedTo = [], shoutIds = [];
if (shouts) {
	shouts = shouts.split(',');
	$(shouts).each(function(i, code){
		code = code.split('|');
		shoutIds.push(code[0]); shoutedTo.push(code[1]);
		document.write('
<style>#shout-' + code[0] + '{ display: none; }</style>

');
	});
	document.write('
<style>#shout-' + shoutIds.sort().reverse().join('-') + '{ display: none; }</style>

');
}
	</pre>
</li>
</ol>
<p>Additionally, I set up a callback page and a very basic form of cross-domain requests (using images) ((Keep in mind that, for security reasons, XMLHttpRequest would not allow me to communicate with my server from digg.com. I thus used (new Image).src to ping the script I set up.)) to inform me of the success of the different stages of the worm (infection, bar disabling, propagation) for each user.</p>
<p>Check out the full script <a href="/wp-content/articles/dugg/dugg.php.txt">here</a>.</p>
<h3>Preventing it</h3>
<p>First of all, it&#8217;s important to constantly keep in mind that user-supplied information should be untrusted. Whenever you input or output information that was originated by a 3rd party, extra caution should be taken.</p>
<p>For PHP developers, preventing XSS exploits usually means passing all user-supplied info through the <code class="inline">htmlentities()</code> function. The caution part is not a cliche, or a meaningless recommendation. It might be obvious for you, as a developer, to escape <code class="inline">$_POST['value']</code> but escaping <code class="inline">$_SERVER['HTTP_USER_AGENT']</code> takes undoubtedly more attention.</p>
<p>The Symfony framework provides one of the arguably most elegant solutions to this problem, with its built-in XSS protection, virtually transparent to the developer. Learn more about <a href="http://www.symfony-project.org/book/1_2/07-Inside-the-View-Layer#chapter_07_output-escaping">this method</a>.</p>
<h3>Conclusion</h3>
<p>I enabled the worm on Digg to try it out with my friends, and it quickly began to spread. After succeeding and collecting about 20 users, I quickly commented it out and let the Digg crew know. Jen Burton, the community manager, responded really quickly, and within an hour or two ((Unlike Twitter)) they had fixed the bug and updated the production site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devthought.com/2009/04/18/the-digg-worm-that-wasnt/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

