<?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>timwhitlock.info &#187; Fail</title>
	<atom:link href="http://timwhitlock.info/blog/tag/fail/feed/" rel="self" type="application/rss+xml" />
	<link>http://timwhitlock.info</link>
	<description>Tim Whitlock&#039;s personal site and blog</description>
	<lastBuildDate>Thu, 15 Dec 2011 13:51:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>OAuth Fail</title>
		<link>http://timwhitlock.info/blog/2009/07/28/oauth-fail/</link>
		<comments>http://timwhitlock.info/blog/2009/07/28/oauth-fail/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 22:34:27 +0000</pubDate>
		<dc:creator>tim</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Fail]]></category>
		<category><![CDATA[OAuth]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://web.2point1.com/2009/07/28/oauth-fail/</guid>
		<description><![CDATA[The day a thousand apps stool still I noticed some weeks ago that Twitter&#8217;s OAuth implementation didn&#8217;t appear to be verifying signatures. I knew this because I purposefully set an invalid access token which was accepted unconditionally. I thought this was odd, but as a newbie to OAuth I was just happy that my app [...]]]></description>
			<content:encoded><![CDATA[<h3>The day a thousand apps stool still</h3>
<p><strong>I noticed <a href="http://twitter.com/timwhitlock/status/2697185141" target="_blank">some weeks ago</a> that Twitter&#8217;s <a href="http://oauth.net/" target="_blank">OAuth</a> implementation didn&#8217;t appear to be verifying signatures</strong>. I knew this because I purposefully set an invalid access token which was accepted unconditionally. I thought this was odd, but as a newbie to OAuth I was just happy that my app was working, so I filed the problem at the back of my mind under &#8220;deal with it if it becomes a problem&#8221;. Today (the week I release by beloved <a href="http://twitblock.org/" target="_blank">TwitBlock</a> app) it very suddenly became a problem.</p>
<p><span id="more-126"></span>It seems that eventually they decided to fix the security hole, except they did it without telling anyone. In their defence this needed to be done quickly, and they were only going to be implementing what we all believed was already in place, namely the well-documented <a href="http://oauth.net/core/1.0a" target="_blank">OAuth standard</a>. The problem was that many people, including myself have publicly released apps that could never have been fully tested.</p>
<p>The damage was already done, i.e. broken apps in the public domain; but the clean up operation didn&#8217;t go well either. At the time of writing, no warning has been posted on <a href="http://status.twitter.com/" target="_blank">status.twitter.com</a>. The first we all knew about the change was broken apps, and disappointed users. A few threads popped up on <a href="http://groups.google.com/group/twitter-development-talk/browse_thread/thread/8d82abd005002ce0/a969b150d73f0c11">this Google Group</a> where devs banged their heads together to work out what was wrong with their code libraries. In my case I eventually tracked down the bug: The main cause of my broken library was that I was signing the full request URL complete with query string. This is incorrect, as <a href="http://oauth.net/core/1.0a#rfc.section.9.1.2" target="_blank">section.9.1.2</a> demonstrates. A bug that, if I&#8217;d been able to test properly in development, would not have made it into production.</p>
<h4>Twitter&#8217;s response</h4>
<p>Although I&#8217;ve not seen an official response, I did see a post on the afore-mentioned Google Group by one of the Twitter API developers. He admitted that they did not approach the situation as they should, but this post may have been deleted because I can no longer find it. I shall post it if I find it again.</p>
<h4>URL encoding bug</h4>
<p>Another bug (which was not actually the main problem) is that PHP&#8217;s rawurlencode function doesn&#8217;t quite fit the bill. <a href="http://oauth.net/core/1.0a#encoding_parameters" target="_blank">OAuth parameter encoding</a> implements RFC3986 whereas <a href="http://php.net/manual/en/function.rawurlencode.php" target="_blank">PHP&#8217;s rawurlencode function</a> implements RFC1738&#8230; the difference is that PHP will encode the &#8220;~&#8221; character. A simple fix is to retro decode the offending character, as follows:</p>
<pre class="code">function oauth_urlencode( $str ){
return str_replace('%7E', '~', rawurlencode($str) );
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://timwhitlock.info/blog/2009/07/28/oauth-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

