<?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>Web Admin Blog &#187; javascript</title>
	<atom:link href="http://www.webadminblog.com/index.php/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webadminblog.com</link>
	<description>Real Web Admins.  Real World Experience.</description>
	<lastBuildDate>Thu, 22 Jul 2010 16:18:30 +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>Development Issues within AJAX Applications: How to Divert Threats</title>
		<link>http://www.webadminblog.com/index.php/2009/11/12/development-issues-within-ajax-applications-how-to-divert-threats/</link>
		<comments>http://www.webadminblog.com/index.php/2009/11/12/development-issues-within-ajax-applications-how-to-divert-threats/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 19:05:00 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[OWASP AppSec DC 2009]]></category>
		<category><![CDATA[Web Application Security]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[issues]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[threats]]></category>
		<category><![CDATA[vulnerabilities]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.webadminblog.com/?p=305</guid>
		<description><![CDATA[This presentation was by Lars Ewe, CTO of Cenzic on AJAX applications and trying to explore the different implications of running AJAX in your environment.  My notes are below: Agenda What is AJAX? AJAX and Web App Security AJAX and Test Automation Vulnerability Examples: XSS, CSRF, &#38; JavaScript Hijacking AJAX Best Security Practices Demo Q&#38;A [...]]]></description>
			<content:encoded><![CDATA[<p>This presentation was by Lars Ewe, CTO of Cenzic on AJAX applications and trying to explore the different implications of running AJAX in your environment.  My notes are below:</p>
<p><span style="text-decoration: underline;"><strong>Agenda</strong></span></p>
<ul>
<li>What is AJAX?</li>
<li>AJAX and Web App Security</li>
<li>AJAX and Test Automation</li>
<li>Vulnerability Examples: XSS, CSRF, &amp; JavaScript Hijacking</li>
<li>AJAX Best Security Practices</li>
<li>Demo</li>
<li>Q&amp;A</li>
</ul>
<p><span style="text-decoration: underline;"><strong>What is AJAX?</strong></span></p>
<ul>
<li>Asynchronous JavaScript And XML</li>
<li>AJAX allows for a new generation of more dynamic, more interactive, faster Web 2.0 applications</li>
<li>AJAX leverages existing technologies, such as DHTML, CSS&lt; DOM, JSON, and the (a)synchronous XMLHTTPRequest (XHR)</li>
<li>Not just a set of technologies, but a new Web application development approach and methodology</li>
<li>XHR allows for (a)synchronous server requests without the need for a full page reload</li>
<li>XHR "downstream" payload can be
<ul>
<li>XML, JSON, HTML/JavaScript snippets, plain text, serialized data, basically pretty much anything...</li>
</ul>
</li>
<li>Responses often get further processed using JavaScript and result in dynamic web page content changes through DOM modifications</li>
</ul>
<p><span style="text-decoration: underline;"><strong>AJAX Code Example</strong></span></p>
<p><code>xhr = new XMLHttprequest();<br />
xhr.open("GET", AJAX_call?foo-bar, true);<br />
xhr.onreadystatechange = processResponse;<br />
xhr.send(null);<br />
function processResponse() {<br />
if (xhr.readyState == 4) {<br />
if (request.status == 200) {<br />
response = xhr.responseText;<br />
...<br />
}<br />
}<br />
}</code></p>
<p><span style="text-decoration: underline;"><strong>XHR and the Same Origin Policy</strong></span></p>
<ul>
<li>Same origin policy is a key browser security mechanism
<ul>
<li>To prevent any cross-domain data leakage, etc</li>
<li>With JavaScript it doesn't allow JavaScript from origin A to access content/data from origin B</li>
<li>Origin refers to the domain name, port, and protocol</li>
</ul>
</li>
<li>In the case of XHR, the same origin policy does not allow for any cross-domain XHR requests
<ul>
<li>Developers often don't like this at all!</li>
</ul>
</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Common Cross Domain Workarounds</strong></span></p>
<p>Cross-domain access is often still implemented by various means, such as:</p>
<ul>
<li>Open / Application (server-based) proxies</li>
<li>Flash &amp; Java Applets (depending on crossdomain.xml)
<ul>
<li>Ex: FlashXMLHttpRequest by Julien Couvreur</li>
</ul>
</li>
<li>RESTful web service with JavaScript callback and JSON response
<ul>
<li>EX: JSONscriptRequest by Jason Levitt</li>
</ul>
</li>
</ul>
<p><span style="text-decoration: underline;"><strong>AJAX Frameworks</strong></span></p>
<ul>
<li>AJAX frameworks are often categorized as either "Client" or "Proxy/Server" framework</li>
<li>"Proxy/Server" frameworks sometimes result in unintended method/functionality exposure</li>
<li>Beware of any kind of "Debugging mode" (Ex: Direct Web Remoting (DWR) debug=true)</li>
<li>Remember: Attackers can easily "fingerprint" AJAX frameworks</li>
<li>Beware of JavaScript Hijacking
<ul>
<li>Don't use HTTP GET for "upstream"</li>
<li>Prefix "downstream" JavaScript with "while(1);"</li>
</ul>
</li>
</ul>
<p style="padding-left: 30px;"><span style="text-decoration: underline;"><strong>AJAX and Web App Security</strong></span></p>
<ul>
<li>AJAX potentially increases the attack surface
<ul>
<li>More "hidden" calls mean more potential security holes</li>
</ul>
</li>
<li>AJAX developers sometimes pay less attention to security, due to it's "hidden" nature
<ul>
<li>Basically the old mistake of security by obscurity</li>
</ul>
</li>
<li>AJAX developers sometimes tend to rely on client side validation
<ul>
<li>An approach that is just as flawed with or without AJAX</li>
</ul>
</li>
<li>Mash-up calls/functionality are often less secure by design
<ul>
<li>3rd party APIs (Ex: feeds, blogs, search APIs, etc) are often designed with ease of use, not security in mind</li>
<li>Mash-ups often lack clear security boundaries (who validates, who filters, who encodes/decodes, etc)</li>
<li>Mash-ups often result in untrusted cross-domain access workarounds</li>
</ul>
</li>
<li>AJAX sometimes promotes dynamic code (JavaScript) execution of untrusted response data</li>
</ul>
<p><span style="text-decoration: underline;"><strong>AJAX / Web 2.0 and Test Automation</strong></span></p>
<ul>
<li>Spidering is more complex than just processing ANCHOR HREF's; various events need to be simulated (Ex: mouseover, keydown, keyup, onclick, onfocus, onblur, etc)</li>
<li>Timer events and dynamic DOM changes need to be observed</li>
<li>Use of non-standard data formats for both requests and responses make injection and detection hard to automate</li>
<li>Page changes after XHR requests can sometimes be delayed</li>
<li>In short, you need to have browser like behavior (JavaScript engine, DOM &amp; event management, etc)</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Cross-Site Scripting (XSS)</strong></span></p>
<ul>
<li>AJAX is changing the game a little bit since the script tag may already be there, just need to look for JSON or JavaScript snippets to inject yourself into</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Cross-Site Request Forgery (CSRF)</strong></span></p>
<ul>
<li>Want to send a token for AJAX requests as well</li>
</ul>
<p><span style="text-decoration: underline;"><strong>JavaScript Hijacking</strong></span></p>
<ul>
<li>Attacker code (override Array constructor)</li>
<li>Render the JavaScript on the wire useless to anyone who doesn't have access to the code itself</li>
<li>The attacker cannot sanitize the JavaScript since they do not have access to the code</li>
</ul>
<p><span style="text-decoration: underline;"><strong>AJAX Best Security Practices</strong></span></p>
<p>Pretty much all the usual Web app security best practices apply:</p>
<ul>
<li>Analyze and know your security boundaries and attack surfaces</li>
<li>Beware of reliance on client-side security measures</li>
<li>Assume the worst case scenario for all 3rd party interations
<ul>
<li>3rd parties can inherently not be trusted!</li>
</ul>
</li>
<li>Be extremely careful when circumventing same origin policy</li>
<li>Avoid/limit the use of dynamic code/eval()</li>
<li>Beware of JavaScript Hijacking</li>
<li>Implement anti-CSRF defenses</li>
</ul>
<ul>
<li></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.webadminblog.com/index.php/2009/11/12/development-issues-within-ajax-applications-how-to-divert-threats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
