<?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>Jakub Korab &#187; security</title>
	<atom:link href="http://www.jakubkorab.net/category/technology/security/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jakubkorab.net</link>
	<description>Tech, Opinion, and Doing Stuff</description>
	<lastBuildDate>Fri, 23 Jul 2010 16:27:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ajax Widgets and Web Application Security</title>
		<link>http://www.jakubkorab.net/2007/01/ajax-widgets-and-web-application-security.html</link>
		<comments>http://www.jakubkorab.net/2007/01/ajax-widgets-and-web-application-security.html#comments</comments>
		<pubDate>Tue, 16 Jan 2007 15:31:00 +0000</pubDate>
		<dc:creator>Jake</dc:creator>
				<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.jakubkorab.net/2007/01/ajax-widgets-and-web-application-security</guid>
		<description><![CDATA[I have recently had a requirement in a web application for a WYSIWYG editor as a textarea replacement. Having taken a quick look at some popular Ajax toolkits for the job, it seems that while they all perform to a greater or lesser extent as advertised, it seems that security issues, in particular XSS attacks, [...]]]></description>
			<content:encoded><![CDATA[<p><font SIZE=2 FACE="Arial">I have recently had a requirement in a web application for a WYSIWYG editor as a textarea replacement. Having taken a quick look at some popular Ajax toolkits for the job, it seems that while they all perform to a greater or lesser extent as advertised, it seems that security issues, in particular XSS attacks, were not at the forefront of the developers minds. Dojo in particular has an Editor widget (</font><a HREF="http://dojotoolkit.org/docs/rich_text.html"><u><font COLOR="#0000FF" SIZE=2 FACE="Arial">http://dojotoolkit.org/docs/rich_text.html</font></u></a><font SIZE=2 FACE="Arial">) that sends an HTML string over the wire when the form is submitted. Let&#8217;s examine a standard use case:</font></p>
<ul>
<li><font SIZE=2 FACE="Arial">User fills in a form, formatting a text area using the widget.</font></li>
<li><font SIZE=2 FACE="Arial">The form is submitted and the contents saved in a database.</font></li>
<li><font SIZE=2 FACE="Arial">The content is served up at a later date.</font></li>
<p> </ul>
<p><font SIZE=2 FACE="Arial">This is a prime candidate for an XSS attack. These attacks are essentially about injecting malicious code which instructs the user&#8217;s browser to act in a particular way. The implications can be a bit scary. Imagine that someone sends HTML through your form to the server that contains JavaScript code to redirect the user to another site. When the server displays the malicious content to a user, they are redirected to a site that looks like the one they came from, and prompts the user for their username and password. The user re-enters their details to log in &#8211; and their credentials have been stolen.</font></p>
<p><font SIZE=2 FACE="Arial">So why does the widget expose you to this sort of attack? The user can only use the buttons available to the to format text, and any code that they type in directly into the editor will be escaped &#8211; so the user&#8217;s</font></p>
<p><font SIZE=2 FACE="Arial">&lt;script language=&quot;JavaScript&quot;&gt;window.location = maliciousSite;&lt;/script&gt;</font> </p>
<p><font SIZE=2 FACE="Arial">will become:</font> </p>
<p><font SIZE=2 FACE="Arial">&amp;lt;script language=&quot;javascript&quot;&amp;gt;window.location = maliciousSite;&amp;lt;/script&amp;gt;</font> </p>
<p><font SIZE=2 FACE="Arial">The problem with that is that a bad guy won&#8217;t be using your nice interface. They view the form, see that it&#8217;s sending HTML and simply craft a request with the malicious code. If your application blindly accepts the input, you are vulnerable. Server side validation helps, but to hand-craft a catch-all validation mechanism that accepts only certain HTML tags is a non-trivial task (especially on a deadline). This approach is also potentially flawed as your validations will inevitably allow certain cases through to the exclusion of others (such as allowing &lt;strong&gt; but not &lt;script&gt;) &#8211; see </font><a HREF="http://www.owasp.org/index.php/Positive_security_model"><u><font COLOR="#0000FF" SIZE=2 FACE="Arial">http://www.owasp.org/index.php/Positive_security_model</font></u></a><font SIZE=2 FACE="Arial"> as to why this is a bad idea.</font></p>
<p><font SIZE=2 FACE="Arial">A better option (though not a replacement for validation, which you should apply all the time anyway &#8211; but you already do this, right?) would be to use a widget which does not send potentially nasty characters, or to modify the Editor widget to escape the HTML stream in some way (such as into a wiki format) before sending. In the use case above, you would need to apply custom formatting on the server for the text to be displayed as intended by the user when it is served up again.</font></p>
<p><font SIZE=2 FACE="Arial">The Open Web Application Security Project maintain a list of security principles (</font><a HREF="http://www.owasp.org/index.php/Category:Principle"><u><font COLOR="#0000FF" SIZE=2 FACE="Arial">http://www.owasp.org/index.php/Category:Principle</font></u></a><font SIZE=2 FACE="Arial">) that you should keep in mind when developing web apps.</font></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jakubkorab.net/2007/01/ajax-widgets-and-web-application-security.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
