Weird Thoughts From Eric's Head

Tags - Categories : All | AJAX | BUSINESS | PERSONAL | PROGRAMMING | BOOK REVIEW

A good response to the eweek Ajax security article

Over on port80software there is a great response to the eweek article on Ajax Security. Check it out here: http://www.port80software.com/200ok/archive/2006/08/04/2424.aspx. The article sounds just like me when I talk in front of user groups!

Eric Pascarello
Coauthor of Ajax In Action
Moderator of HTML/JavaScript at www.JavaRanch.com
Author of: JavaScript: Your Visual Blueprint for building Dynamic Web Pages


The problem with the rant is that the author doesn't offer any solutions to the issues Billy brought up, and makes some basic mistakes. This is why Billy is right and the author of the rant needs to be very particular about defending the indefensible. Ajax apps cross the trust boundary more than any other type of web app. By definition, there will be more client side state, and more client side code. How an app handles that client-side state and provide integrity controls or properly escapes it and understands the risks of cross-domain XHR and untrusted site JSON decoding, Ajax apps will be at risk for some time to come. Unfortunately, unless the user is using a particularly security conscious Ajax toolkit or knows exactly what they're doing, they'll cut n paste insecure snippets from Ajax in Action (e.g. listing 5.9 on page 191) or Ajax Hacks (e.g. "Array return value" on page 101 - which has a warning but no actual code to prevent XSS). Until ALL examples in ALL references and ALL Ajax frameworks are secure-ish, and developers get the message, it's going to be a bumper year or three for security consultants. Let's not have that. Don't bash us researchers - let's bug bash the references, the toolkits and help the developers get it right! Join me in stamping it out! Please make the second edition of Ajax in Action secure - make all the examples secure.
Andrew,

People think Ajax is this new big security threat. When you stand back and look at an Ajax application, you have a form submission to the server. The server has no clue what in the world it is interacting with. There is no special "Hey I am Ajax boolean" (unless you coded one in the header!)

So everything still applies with normal traditional postback model. Check for injections (SQL, JavaScript, VBScript, HTML, etc.) People say but I can see the XMLHtpRequest Object and I say I can see your form with he method, fields, and action! What is the difference. I can spoof an XMLHtttpRequest Object and I can spoof a form submission.

The last is my business logic is out in the open. WHY did YOU put it there than? Do you put your business logic for the post back model on the client too. So what in the world changed? If security is a BIG deal, than use the client as the "visual rendering" part of the application.

I am working on a large article that covers these topics in detail. We will see if it ever reaches the light of day since I am busy as can be lately.

Eric

Eric, you're absolutely right. There's only really one newish issue, and that's JSON injection, which is really about JS command injection, an old friend.

So basically, what we need is for people to understand that JS does not provide a htmlentities() escaping function, and they must escape data regardless. Prototype has this function (

string.escapeHTML()
) which does a moderately awful job in ISO 8859-1, and the other Ajax frameworks should all provide one as well. However, compared to PHP's htmlentities() which can handle other encodings, Prototype's function is too simplistic. Therefore, in my personal opinion, escaping should be done on the server, where there is far more smarts than is the case today. But no one has written this (yet).

I'd really like to see all examples which take dynamic input from the server or from the user to be retrofitted with safety. Escaping data is not optional, so it deserves to be in every Ajax book.

The problem with many apps I've reviewed is that they only want to write the functionality once. If they have written it in the client side layer, those folks are loathe to replicate the logic back on the server. This applies to some very big and very "enterprise" apps, including Tibco GI. For these type of apps (notably marketing themselves as 100% client side) they see the server as this evil thing. It's not. Such folks are doomed to repeat the mistakes of the mid 90's again.

I'm writing a book on Ajax Security, and the topic of where business logic should reside is covered off in there. I hope your article does see the light of day as you're extremely respected for your work on Ajax in Action, and getting this message through is extremely important.

AH! I forgot the JSON part that you mentioned. Wrote that comment at 4AM after my animals choose to freak out.

Using an outside source for JSON is like stepping off a curb on a busy street at a cross walk. You are hoping that a guy abides by the law that he stops at the cross walk when you are in it. But he might be on his cell, eatting fast food (real fast food <-bad joke), or just likes to hit things and run you over. Now hat is the smae thing with a external JSON that you have to evaluate with script tags. You have to trust that that source is not full of ads, pop ups, redirect links, etc.

Now I could say, go use a webservice instead with the server or use a proxy on the server to get this webservice. That webservice too could be full of the same crap just in XML format. So yes we need to escape the code as you mentioned. The other thing is trust. Can we trust that X server is going to always prove Y serice with no Z effects.

Why do books and articles tend to leave this out. Common Sense, Page Space, and time are major factors. I know why I talk to user groups I stress validation, injection, and trust.

Good Luck on the book, I do not wish writing a book on anyone!

Eric



Add a comment

Title
Body
HTML : b, i, blockquote, br, p, pre, a href="", ul, ol, li
Math Quiz 5 + 1 = (Helps stop blog spam)
Name
E-mail address
Website
Remember me Yes  No 

E-mail addresses are not publicly displayed, so please only leave your e-mail address if you would like to be notified when new comments are added to this blog entry (you can opt-out later).

TrackBack to http://radio.javaranch.com/pascarello/addTrackBack.action?entry=1156083943876