« Who are Hackers? Part II: Hacking for Money | Main | Hacking's new business model »

JavaScript Hijacking: Who's Responsible?

We just released our report on the first (and to our knowledge the only) type of attack that specifically targets Ajax-style web applications. The attack is called JavaScript Hijacking. The report is here.

As part of the work, we took a look at 12 Ajax frameworks, including Google's GWT, Microsoft Atlas, Yahoo! UI, and a number of open source projects. A lot of the open source projects provide only client-side JavaScript libraries. In the report we point out that almost none of the frameworks protect against JavaScript Hijacking or give programmers any indication that there's anything they need to protect against themselves.

Thus-far, nobody has questioned us on the technical aspects of the attack, and quite a few of the framework maintainers have said they plan to address the problem. But we've taken some flak for our proposed solutions from a few owners of client-side JavaScript libraries. It boils down to one sentence in the report:

"Preventing JavaScript Hijacking requires a secure server-side implementation, but it is incumbent upon the client-side libraries to promote good security practices."

Some of the client-side guys aren't so happy with that. They say that security is totally a server-side problem. Keep in mind, most of these projects don't say a thing about writing a secure server in their documentation, and worse yet, some of them actually require the server to be vulnerable unless the application programmer wants to start monkeying around in the guts of the framework. Ugh.

Now that I'm done writing the report, I can ditch the any semblance of an even or balanced tone, so let me try saying it again. Here's the deal: if you're going to write some code that you expect programmers to re-use, and if that code walks people right into creating a security cesspool, you are doing the world a disservice. Don't be surprised when I tell the world to steer clear of your stuff.

TrackBack

Listed below are links to weblogs that reference JavaScript Hijacking: Who's Responsible?:

» Fortify finds Web 2.0 security hosed - "An application can be mashup-friendly or it can be secure, but it cannot be both" from 1 Raindrop
Fortify released a new paper on Javascript hijacking. The paper looks at 12 Ajax frameworks, including Google's GWT, Microsoft Atlas, Yahoo! UI, and a number of open source projects, to see which are vulnerable to Javscript hijacking, described as the ... [Read More]

Comments (11)

Buben Razuma:

How about Stefano Di Paola and Giorgio Fedon's lecture "Subverting AJAX" from 23rd Chaos Communication Congress?
http://events.ccc.de/congress/2006/Fahrplan/events/1602.en.html

It seems to use quite similar techniques, doesn't it?

Jeff:

I have a question, you only mention JSON. Can this vulnerability be exploited if you are using XML with AJAX instead of JSON?

Hi Buben, the "Subverting Ajax" paper talks about using Ajax-style techniques to develop sophisticated exploits for cross-site scripting vulnerabilities and a few other kinds of vulnerabilities. It's a good paper.

However, JavaScript Hijacking doesn't require the presence of a cross-site scripting vulnerability. It allows an attacker to read data across domains. None of the attack code runs in the vulnerable domain. Instead, code from the vulnerable domain runs in the attacker's domain.

A few people have mentioned this paper to me, so I've added it to the JavaScript Hijacking FAQ:
http://www.fortifysoftware.com/security-resources/javascripthijacking.jsp

Hi Jeff, JavaScript Hijacking only works against JSON and other data transport formats that use JavaScript syntax. XML is safe.

Guy:

Hi,

I would like to introduce you to a new technology called http://www.visualwebgui.com which provides a unique way to create AJAX applications by providing full WinForms like development including design time support. The architecture eliminates most of AJAX soft spots by simply
returning back to server based computing but still having a dynamic AJAX based UI. It also has been said by developers to boost productivity to R.A.D. levels with out limiting your options.

Guy

Brian Chess:

Hey Guy, I poked around on the visualwebgui site for a little bit, but I didn't see any mention of security in the documentation. Looks like developers are just supposed to know what makes a secure application? Uh oh. Sounds like trouble.

Hi,

You'll be happy to hear that we've added automatic removal of security delimiters inside Prototype's latest release (http://prototypejs.org/2007/4/24/release-candidate-3).

This means that JSON data returned in the following form will be correctly escaped if it is called by an Ajax request, but will be unavailable to malicious attempts:

/* - secure -
{...}
*/

The delimiter pattern is of course configurable.

I wanted to propose (and solicit comments on) another possible anti-hijacking prefix:

true? alert('Javascript hijack attempted!'):

Authorized client code then does:

eval('(!' + response + ')')

The response itself does not require modification (only the '!' prefix) and an unauthorized <script> reference generates an alert.

Brian Chess:

I like it. It's short, elegant, and incurs just about the minimum imaginable runtime overhead. Whether or not to actually do an alert() is debatable--can you give the user adequate information about what's going on, or are they going to be left scared and confused? But the general technique you're proposing doesn't require you to call alert(). I think this is my favorite solution yet.

Christopher Vogt:

Hej,

I read the report. I didn't try it, but if what you write is correct, then isn't that "simply" a browser bug?

A browser should not submit any cookies in an XMLHttpRequest, to which issuing script has no access.

That is nothing that can be fixed in JavaScript.

I am very interested in comments.

Chris

Brian Chess:

Hey Chris, you're right, the browsers could fix JavaScript Hijacking, but not without breaking existing web pages and mashups that depend on the current behavior. Current Web standards and browser implementations make secure programming hard. In the short term, we have to live with what we've got and make the best of it. Long term, we need better standards and browser implementations that make it possible for mere mortal web programmers to write secure code.

Brian

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Presented By

About

This page contains a single entry from the blog posted on April 1, 2007 10:42 PM.

The previous post in this blog was Who are Hackers? Part II: Hacking for Money.

The next post in this blog is Hacking's new business model.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.34