Slashdot Mirror


Is Your AJAX App Secure?

ShaolinTiger writes "An article looking in detail at some of the security problems with AJAX, how to find them and how to approach them or fix them. Security with AJAX is of course an important consideration as it's asychronous and a malicious user could write data back to your database if implemented incorrectly."

142 comments

  1. JUG by eldavojohn · · Score: 3, Insightful
    Well, I'd like to say that this is an issue rarely addressed--which is alarming considering how widely AJAX is used these days.

    In the article, he addresses a token used to generate random strings:
    One should let the page, or some include javascript, generated on the server side, include some token that the performs some operation on which gives a result which is used in any consecutive request to the webserver. The webserver should not allow any request with another 'sequence number', so to speak.

    The servers' 'challenge-string' should be as random as possible in order to make it non-predictable: if one could guess what the next sequence number will be, it is again wide open for abuse.
    And I think one of the most commonly used Universally Unique IDentifiers (UUID) generators is Java UUID Generator (JUG) which can be used by any type of application that can communicate with Java libraries (most apps capable of XML messaging can anyways).

    Of course, this can be no better than pseudorandom as we all remember from our courses. :-)
    --
    My work here is dung.
    1. Re:JUG by stunt_penguin · · Score: 4, Informative

      It should also be possible to add a function that you run for each http request that filters the request for common attacks, and also handles the key the parent talks about.

      So when you're writing a command to make a request, you pass your request into your pre-written function which has any request-related security processes written into it. This way things are reasonably seamless in that you don't have to worry about security every time. I think.

      /relative JS noob who writes a lot of actionscript so therefore *thinks* he knows a language ;o)

      --
      When the posters fear their moderators, there is tyranny; when the moderators fears the posters, there is liberty.
    2. Re:JUG by Z34107 · · Score: 1

      Actually, UUIDs are NOT (pseudo)random. The generator has to be mathematically guaranteed never to generate the same UUID twice, or otherwise, the whole concept of a UUID breaks down.

      --
      DATABASE WOW WOW
    3. Re:JUG by Anonymous Coward · · Score: 0

      You don't remember the random quasars article?

    4. Re:JUG by thedji · · Score: 1

      Good response for a self-proclaimed 'n00b' :)

      One good way to achieve this without having to run generic input validation on every input field is to use a WAF (Web Application Firewall) such as mod_security.

      Of course you should still do highly specific validation (like only allowing 2 decimals places in cash amounts and 0-100 for percentage amounts, etc) on the server side of your app.

      --
      ... and then there were none
  2. it's not secure, check out googe maps by Gravis+Zero · · Score: 1, Funny

    AJAX is not secure! if you look at google maps you can see my house... it's just sitting there on the screen waiting to be bombed. ahh.. my frickin' house!

    --
    Anons need not reply. Questions end with a question mark.
  3. How is this different by El_Muerte_TDS · · Score: 5, Insightful

    How is this different from securing a "normal" dynamic website?

    1. Re:How is this different by grazzy · · Score: 5, Insightful

      There was a new buzzword in the middle of the sentence.

    2. Re:How is this different by Anonymous Coward · · Score: 0

      You don't get to the front page of Slashdot if your article is called "Do you have any common sense whatsoever?"

    3. Re:How is this different by Anonymous Coward · · Score: 0

      This is true, but there are a large number of idiots with keyboards out there who don't any common sense what-so-ever. If we see a "Web 2.0 bubble" develop, you can bet your bottom dollar those idiots will be all over the web (2.0).

    4. Re:How is this different by stromthurman · · Score: 4, Informative

      You are absolutely correct. The example the author provides of the .len paramter not being checked by the web app is a prime example of the kinds of problems that plague any web application, AJAX or not. Input validation, session validation, user authentication and so forth are required by EVERY web application. This part particularly irritated me:



      If the XmlHttp-interface is merely protected by cookies, exploiting this is all the easier: the moment you get the browser to make a request to that website, your browser is happily sending any cookies along with it.


      That is true of most common methods of session management. For instance, PHP's very own built-in session management, which many people use, uses nothing more than a cookie value to manage the session. If you want to secure any web-app that uses sessions through cookies (again, AJAX or not) you'd better be using an HTTPS connection and cookies that are flagged to only be transmitted across a secure connection, and the author never touches on this point.

      Add to that the whole nonsense about POST being "more secure" or "harder to fake" and it becomes clear that these are the words of a novice web programmer. And clearly this article illustrates nothing more than a web programmer's first experiences with examining the security of a web app.


      But, he's linked to slashdot's main page, with plenty of AdSense links... so good for him.

      --
      I have discovered a truly remarkable sig which this margin is too small to contain.
    5. Re:How is this different by portcombine · · Score: 1

      Actually, as far as I understand what _does_ make POST more secure is that parameters (user credentials when logging in, ...) don't show up in the web servers log file?

    6. Re:How is this different by Trails · · Score: 1

      I thhink what the author meant was that GET requests are easier to muck with.

      We all know someone with malicious intent and a modicum of knowledge canfarily easily fake either, and the incremental difficulty from of POST as compared to GET is negligible.

      However, a bored 13 year old, with minimal knwoledge, can easily muck with a GET, not so much with a POST. A POST requires a bit more know-how, hence limiting the user base that has the ability to dick around with your site, hence offering greater security.

    7. Re:How is this different by Beryllium+Sphere(tm) · · Score: 2, Funny

      Now, now, be fair.

      The article proposes one kind of attack: "it would leave massive DoS possibilities if I can create an HTML page that, using Javascript, can request thousands of concurrent web-pages from a web-site".

      An attack like that would hit the web server's current directory, ".", like a slasher. An attack site that takes thousands of incoming connections and then floods the victim, implementing this "slash dot" effect, is a brilliant innovation.

    8. Re:How is this different by cyngus · · Score: 1

      Its not. As far as your server is concerned, there is no difference. What is AJAX? Its a way to send an HTTP request without changing the page displayed in the browser. From the server point of view, an HTTP request is an HTTP request is an HTTP request. Rule #1 of web applications, trust no parameter. I spend probably 20% of my time validating parameters in one way or the other. Let's say we're talking about a forum and you receive a delete request along with a post id. First, validate the post ID. Then validate that this post belongs to the user (assuming you're using something like the Tomcat Realms session management system). I mean, these are basics and AJAX doesn't change the way the game is played. It provides a different path for submitting HTTP requests, but it doesn't provide a fundamentally different HTTP request.

    9. Re:How is this different by misleb · · Score: 1
      However, a bored 13 year old, with minimal knwoledge, can easily muck with a GET, not so much with a POST. A POST requires a bit more know-how, hence limiting the user base that has the ability to dick around with your site, hence offering greater security.
      But isn't it the kids with just a bit more know-how that you have to worry about?

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    10. Re:How is this different by Anonymous Coward · · Score: 0
      A POST requires a bit more know-how,


      Or a Firefox extension.

      A

    11. Re:How is this different by Trails · · Score: 1

      Well, it's all of them really. Look, security, to some degree, is a numbers game. Nothing is perfectly secure. It's about reducing the ease of exploitation. Coverting from GET to POST is EASY, and, clearly, less people know how to create a POST as opposed to a GET.

      To analyse a POST, one needs: knowledge of HTML and javascript, and to spend time reading the source of the form in question to figure out what the post looks like.

      To create a fake POST, one needs: knowledge of how HTTP headers work, and either telnet knwoledge or a firefox extension (courtesy of post below).

      To analyse a GET, one needs: a browser

      To create a fake GET, one needs: a browser.

      To convert from GET to POST does NOT make you app secure. However, it'll reduce the number of phony requests you have to deal with.

    12. Re:How is this different by the+chao+goes+mu · · Score: 1

      There are modules which can be used to record POST data, but for a default setup you are correct.

      --
      Boys from the City. Not yet caught by the Whirlwind of Progress. Feed soda pop to the thirsty pigs.
    13. Re:How is this different by the+chao+goes+mu · · Score: 1

      Actually, to fake a post most of the time you simply need to save a local copy of the relevant form and manually edit a field or two (or turn a hidden field into a text box, or something similar). It is much easier than you suggest in 90+% of the cases. (Yes, extensive use of javascript makes this harder, but most websites use pretty simple forms, and any JS is for input validation. You can usually ignore the JS, especially if you are mangling a hidden field -- as JS usually does no validation on hidden fields.)

      --
      Boys from the City. Not yet caught by the Whirlwind of Progress. Feed soda pop to the thirsty pigs.
    14. Re:How is this different by NickFitz · · Score: 1

      That's not something new. I can host a web page which uses a JavaScript setTimeout trigger to repeatedly download your site's homepage into an Image object - it doesn't matter that it's not an image. If I then get that page Slashdotted, all Slashdot's readers who RTFA and have JS enabled will, for the time it takes to read my page, be participating in a DDOS attack against your website. This has been possible since Netscape 3 in 1996, and doesn't involve Ajax at all. As a number of commenters to TFA and here on /. have pointed out, there's nothing in there specifically to do with a threat posed solely by the use of Ajax.

      --
      Using HTML in email is like putting sound effects on your phone calls. Just say <strong>no</strong>.
    15. Re:How is this different by Eivind · · Score: 1
      Not different at all.

      To the security of a site, it makes precisely zero difference if the *clientside* is running javascript, asynchronous http-requests, or consists of a guy writing "telnet yourhost 80"

      You must remain secure regardless of what the client sends you. You cannot trust the client. This does in no way whatsoever change if "Ajax" or any other buzzword of the day is involved.

    16. Re:How is this different by Zaiff+Urgulbunger · · Score: 1

      I think Beryllium Sphere(tm) maybe was being sarcastic?

      Anyway, the article itself contained absolutely nothing new imho. Worse, it seems to suggest craptastic security measures such as checking referer or user-agent strings, and using POST rather than GET because its harder to fake! I mean, yeah, but none of these things will actually make the application safer in any real sense -- only very very slightly moderately harder to attack. ish.

      And what was this about:
      "If I would be able to insert Javascript in the web-application I am currently looking at in my other browser window, I would be able to easily delete any post the site allows me to delete. Now that doesn't seem all that destructive as it only affects that user? Wrong, any user visiting will have its own posts deleted. Ouch."

      How is this relevant to sites using AJAX? I mean, *any* website that allows someone to inject script is vulnerable.

      Oh and this classic:
      "The question is -- can we perform an action while somebody is logged in somewhere else. It is basically XSS/CSS (Cross Site Scripting) but then again, it isn't."

      Seriously.... this article was written by a twelve year old. If this is the best "darknet.org.uk" can do, then really, we do not need to worry too much about being hacked any time soon (webmaster of the ring-tone website accepted... but then, they probably don't freqeunt slashdot!! :D)

      Appologies for the rant!! But sometimes there are some rubbish articles posted to /. and they deserve to be flamed! ;)

    17. Re:How is this different by xs_anyType · · Score: 1

      There is one major error that I haven't seen anyone point out yet. In the general sense, XMLHttpRequest does not introduce XSS risks: you can't make off-domain requests with XHR.

    18. Re:How is this different by budgenator · · Score: 1

      What is AJAX? it is a method to get the marketingdroids, graphic artists and "web" designers off your ass about including unreasonable amounts gratutuious graphics and flash bullshit. If the simple page didn't include 1 meg of crap, you wouldn't even need AJAX; yeah I know google maps is a cool AJAXs app and necessary, but most I've seen is just AJAX for AJAX's sake.

      --
      Apocalypse Cancelled, Sorry, No Ticket Refunds
    19. Re:How is this different by lord_sarpedon · · Score: 1

      You hit the proverbial nail on the head. The article screams "Newbie" and is by no means newsworthy. If it's not the bits about using POST to be more "secure", then it's the fact that it presents nothing that is AJAX-specific. Sensationalist garbage.

      --
      "Strangers have the best candy" -Me
  4. Obligatory by frodo+from+middle+ea · · Score: 3, Funny

    I write only static HTML you insensitive clod.

    --
    for the last time people, I am "frodo from middle eaRTH", not "middle eaST".
    1. Re:Obligatory by skurrier · · Score: 1

      I only write plain text, in uppercase, you insensitive clod.

    2. Re:Obligatory by aurb · · Score: 1

      Yes, but is your HTML Secure?

    3. Re:Obligatory by cshark · · Score: 1

      Whatever man, this argument hurts my feelings.
      I'm just going to go back to my hyperlinked help system now.

      --

      This signature has Super Cow Powers

  5. No by hjf · · Score: 0

    No, mine isn't. I developed a Q&D (quick and dirty) AJAX app along with a nasty "write-only" Perl script to manage a server for my own use. It's full of security holes and the server script doesn't even do the most basic sanity checks, it even uses some VERY insecure variable untainting, and runs on thttpd as root. But hey it works, and as I'm the only one using it, on my own internal LAN, well.. I don't mind :D

  6. But we already know this... by liliafan · · Score: 2, Insightful

    Pretty much everything in this article seems to be a complete rehash of things most web developers should already know, you should always be checking for possible xss/css problems, you should never depend on a cookie, never provide more information to the user than they absolutely require, always treat all input as tainted until it has been correctly validated, just because this article relates to a new technology doesn't mean it is refering to new vulnerabilities.

    I am sure that some people can learn a little about security from this article but if you learn anything new reading this, you should go to any sites you have written in the past and take them down right away because chances are you already have a security hole. I recall quite recently a friend of mine was quite shocked that his AJAX application could perform sql injection attacks on his database, on looking at his code he was entirely trusting everything that came to it, I almost slapped him for that mistake.

    --
    GeekServ Unix Consulting Services (http://www.geekserv.com)
    1. Re:But we already know this... by haralder · · Score: 1
      things most web developers should already know

      You are right, they should know it. But I can guarantee that reality is much harder.

    2. Re:But we already know this... by Karma+Farmer · · Score: 1

      Pretty much everything in this article seems to be a complete rehash of things most web developers should already know

      Pretty much everything in this article seems to be a complete rehash of things most web developers should already know is wrong.

      Seriously, I don't think I've ever read a more clueless, half-baked article about web security in my entire life. Most of the advice is misleading or just plain wrong, the author seems to only partially understand even the most basic threats, and clearly has no idea how to describe, recognize, or fix any of them.

    3. Re:But we already know this... by billcopc · · Score: 1

      I always figured security was rather simple, you just have to pretend to be the MPAA/RIAA: treat everything and everyone as criminals. Any data, ANY DATA coming from a browser has to be validated to hell and back. If there's anything sketchy about the request, send back an error message and let the user try again. Any foreign characters ? Escape them if you really want them (e.g. posting code in a forum or CMS), or else loudly complain to the user and tell them to play nice.

      When dealing with web sites, I've always found it very handy to log any suspicious activity, at least in the beginning. This will let you see where and what the red flags are, and maybe give you some insight into what kind of sneaky shit the users are trying to pull. Sometimes it will expose usability problems, like breaking the Back button or maybe one of your forms needs to be simplified/explained. In any case, it will give you tools to harden your app.

      --
      -Billco, Fnarg.com
  7. AJAX App Secure? by digitaldc · · Score: 2, Funny

    If not, you need to clean it up!
    Code cleanliness is next to Dev godliness.

    --
    He who knows best knows how little he knows. - Thomas Jefferson
  8. You're doing it the wrong way by BadAnalogyGuy · · Score: 0, Offtopic

    Force your users to use IE. Make them install ActiveX controls that host your program. Exploit their PCs.

    Sheep need to be led.

    1. Re:You're doing it the wrong way by Anonymous Coward · · Score: 0

      Simon? Is that you?

  9. Challenges of AJAX by cyberjessy · · Score: 3, Interesting

    Security with AJAX is of course an important consideration as it's asychronous and a malicious user could write data back to your database if implemented incorrectly.

    That statement is a little misleading, as security is not directly related to requests being asynchronous. I think what the poster meant is that being asynchronous, AJAX application make lots of calls to the back end. In a non-AJAX app, typically you fetch the data during the page load. In AJAX app, users request sections of the page to be refreshed, meaning a lot more finely grained methods to the backend are exposed.

    non-AJAX:
        LoadMainPage()
    AJAX:
        LoadTitles()
        LoadSections()
        LoadSummary()

    --
    Life is just a conviction.
    1. Re:Challenges of AJAX by misleb · · Score: 1

      Sure, but there are typically any number of links on that non-AJAX page that make similar requests for data. All of which use GET requests... exactly the kind of thing that the author of the article warned against.

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    2. Re:Challenges of AJAX by Anonymous Coward · · Score: 0

      That statement is a little misleading, as security is not directly related to requests being asynchronous. I think what the poster meant is that...

      Having skimmed the article, I think that it's likely that the poster simply doesn't know what "asynchronous" means. He's an idiot. Let me quote you some gems:

      Do you even check referrers or some trivial token such as the user-agent? Chances are you do not even know. Chances are that other people, by now, do.

      Using GET is a major mistake-a-to-make. POST is a lot better, as it harder to fake. The XmlHttpRequest can easily do a POST. But I cannot get a script, for instance I could have embedded one in this article, to do a POST request to another website

      Yes, you can. You just create a hidden form that POSTs to a hidden iframe. You don't need XMLHttpRequest.

      His "my prediction" sequence numbering is a poor reinvention of transaction cookies (note: not HTTP cookies), already widely used. This is a really shitty article, written by an amateur new to the field.

    3. Re:Challenges of AJAX by grimJester · · Score: 1

      Actually, I think AJAX creates security problems because most coders consider problematic input from the user to their app, not necessarily input from their client to their server. I imagine sloppy coders put javascript checks on input for convenience and forget to check the input the server recieves for cases the javascript would have caught.

    4. Re:Challenges of AJAX by supersnail · · Score: 1

      All the "loopholes" described in the rather brain dead article describe security holes at the server end.
      Anyone serioulsly trying to exploit this will not be using javascript and a browser but something like curl and perl.
      At this level there is really no difference between between "get" and "post" as curl can handle both equally easily, and, there is really not much difference between a URL designed to be read directly by the browser and a URL designed to be read by AJAX.
      What the article is really saying is that your web server application is insecure if you code it badly and even if you code it well you can still be subject to DOS attacks.
      This is not news.

      --
      Old COBOL programmers never die. They just code in C.
  10. Enough already by gregarican · · Score: 0, Flamebait
    I am growing sick of hype surrounding the AJAX bandwagon. It reminds me of the mid 1990's when the advent of Java had folks proclaiming how web based applications would be the preferred way of creating new applications across the board. Yeah, right. In short, web based apps have their purpose and can be effective. But they aren't the savior to mankind and the AJAX delivery method has been around for years now. We didn't use crudely fashioned stone tools then either.

    And no, I'm not a hater. I personally count Ruby amongst my programming languages of choice and I have written a couple of Rails applications that my company currently has in production. But the AJAX hype is getting tired.

    1. Re:Enough already by misleb · · Score: 1

      And I'm getting tired of people who have knee jerk reactions to any mention of AJAX regardless of the content. Did you even RTFA? There was no hype in it. Although I am still wondering what the poitn of it was. Seemed to me that everything they talked about would apply to "regular" web pages.

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
  11. Isn't that always a threat? by MikeRT · · Score: 4, Insightful

    Hasn't the threat of a SQL injection always been a threat, dating back to the pre-AJAX days of development? Why is this even news? Proper error handling and input checking should be enough to minimize these problems.

    1. Re:Isn't that always a threat? by _xeno_ · · Score: 1

      No, of course not. I mean, who could ever sneak in something malicious to http://host/report?q=SELECT+%2A+FROM+CUSTOMERS? I really wish I was kidding, the first response to "we should never do this" was "oh, so we should be using POST instead?"

      But, yeah, these types of problems aren't exactly new. Although there are quite a few people out there who seem to believe that if you simply hide the location bar via window.open, you remove all chances of tampering with the request. Likewise with using POST over GET. It's something that people should be able to figure out, but not necessarily something that people do figure out.

      --
      You are in a maze of twisty little relative jumps, all alike.
    2. Re:Isn't that always a threat? by franky999 · · Score: 1

      But it's hip!

    3. Re:Isn't that always a threat? by MyLongNickName · · Score: 1

      Avoid SQL injection by not relying on dynamic SQL queries. Use Stored Procedures, and you avoid a lot of risks. Users do not even need rights to underlying tables. If you insist on dynamically generating SQL based on user input, then triple check everything and pray a lot.

      I don't understand giving attackers a free attack vector in your applications.

      --
      See my journal for slashdot ID's by year. Mine created in 2005. http://slashdot.org/journal/289875/slashdot-ids-by-year
    4. Re:Isn't that always a threat? by Karma+Farmer · · Score: 1

      I really wish I was kidding, the first response to "we should never do this" was "oh, so we should be using POST instead?"

      I really wish I was kidding, but the first thing the article suggests is using POST instead.

    5. Re:Isn't that always a threat? by lukewarmfusion · · Score: 1

      Many developers learn it the hard way - when someone exploits them. My eyes were opened to security when the client's parent company audited our work and found holes.

      I was assigned the job of fixing the problems, leading me to become a ridiculously paranoid developer.

      The point of these articles (heck, I've written articles just like this) is to reach those developers that may not have considered these problems.

      Of course, you also have to convince the idiots out there that security is a concern...

    6. Re:Isn't that always a threat? by MagicM · · Score: 1

      Avoid SQL injection by not concatenating user input into your dynamic SQL queries. Use bind variables, and you avoid a lot of risks while still maintaining all the flexibility. As a bonus, you may end up with improved performance.

      Unless your DBMS doesn't support bind variables. In which case you may want to consider one that does. I hear PostgreSQL is nice.

    7. Re:Isn't that always a threat? by rjstanford · · Score: 2, Informative

      As a bonus, you may end up with improved performance

      While this is true for the most part (and in fact I made a case for it elsewhere on this thread), the one side-effect is that your DBMS can't examine the value of the parameters when determining the query path, possibly resulting in sub-optimal optimization. However, it does result in incredibly repeatable query paths, which is a trade-off I'll take almost any day.

      It still amazes me when you can crash even high-dollar enterprise apps by putting an apostrophe into a free-form text field. [shudder]

      --
      You're special forces then? That's great! I just love your olympics!
    8. Re:Isn't that always a threat? by makomk · · Score: 1

      I really wish I was kidding, but the first thing the article suggests is using POST instead.

      He also says that you can't make a POST request to a website other than the one the page doing the POST is on. This is true if you're using XmlHttpRequest to do the POST, but if you're using standard forms you can. You can even hide a form in a FRAME/IFRAME and use JavaScript to automatically submit it in the background. (Of course, you can't get the content returned in response, but the same is true with GET). LiveJournal had some problems related to this (now mostly fixed).

    9. Re:Isn't that always a threat? by the+chao+goes+mu · · Score: 1

      I know what you mean. At one job I found a web page with the argument (in a GET statement) "include=file.html". I decided to play with it a bit (it wasn't my code and I didn't have any read/write rights to that directory) and tried "include=../../../../../etc/passwd". Surprise! I could read it. And /etc/vfstab, and pretty much everything else I wanted short of /etc/shadow. I also discovered that our cgi executables contained hardcoded username/password pairs visible when this webpage tried to read them as text. My boss' reaction "So, why is this a problem?".

      --
      Boys from the City. Not yet caught by the Whirlwind of Progress. Feed soda pop to the thirsty pigs.
    10. Re:Isn't that always a threat? by stromthurman · · Score: 1

      Treading into the land of off-topicism here, but I encountered a similar thing at a previous job. What was even more awesome was that the code to open the file specified in somescript.pl?template=filename used the Perl open function, without any input validation. So, not only could you read any file, you could also pass in something like: template=filename|ls and execute any command on the server under the privileges of the script's owner.

      --
      I have discovered a truly remarkable sig which this margin is too small to contain.
  12. Poor article. by Anonymous Coward · · Score: 1

    It runs through various ways in which your AJAX app can be insecure. All of which apply to any dynamic page, AJAX or no.
    Then, instead of discussing how to, i dunno, say, actually _check_ your input, it rambles through various techniques of that stalwart of crappy coders: security by obscurity.
    Every solution posited finishes with "Hey, people could still crack this easily, but it makes it that bit more annoying".

    Time here would be much better spent reading some Shiflett (for php newbs of the world), or any "Security goofs 101 and how to _actually_ avoid them", not this "vaguely obfuscate stuff, and use POST" recommendation.

    1/10

  13. Something new ? by Spliffster · · Score: 1

    i fail to see the difference of a webbrowser initiated and a scripted request to a dynamicly generated response. In any way, permission must be checked, the script shall now work on request data nor send data back to a client with insufficient permission. Nothing to see here, move along ... -S

  14. Asynchronous? by Alioth · · Score: 1

    No, security is not important because AJAX is asynchronous - security is important because an AJAX app is exposed to unknown users on the public Internet. The security issues with AJAX are the same as with any web application: don't trust any input and validate it before doing anything important with it. The security issues with the Javascript part (things like, but not limited to cross site scripting and sending things to your clients that may be harmful to them) are the same as any other Javascript-using website.

    1. Re:asynchronous? by Anonymous Coward · · Score: 0

      I believe the idea is that the browser and the server don't need guaranteed agreement on a time frame, and the server does other things until the browser asks for a content refresh. That is, the server doesn't sit and wait for the browser to ask for content; it can handle other requests or exit and let another server instance handle the next request. The browser, on the other hand, may be tied up doing other things when it's supposed to get a refresh (and the refresh comes late), or there may be server lag and the browser continues to allow the user to manipulate the old page until the new data arrives.

      I suppose the implications for security are that you could conceivably form a malicious request by creating two requests that check out okay by themselves, but are mutually incompatible. As a completely contrived example, suppose you had a store that kept user info, including the contents of the current shopping cart, in a database. When the Check-out button is clicked, the amount referred to on-screen is billed to the user's credit card and all the items in the shopping cart are marked as "SHIP TO USER." So if the user has multiple windows/tabs open, he can add a few items to his shopping cart in one window, and then click Check-out in another, and get a few items for free. Of course, being able to exploit this requires a great degree of familiarity with the system, not to mention a great deal of poor design to begin with.

  15. Maybe I'm stupid by LS · · Score: 1

    Can someone explain to me why this is not a problem with regular GET and POST requests? What is special about AJAX that introduces new security problems? Or is this just a chance to write an article using the latest buzzword?

    --
    There is a fine line between being a cultivated citizen and being someone else's crop. - A. J. Patrick Liszkie
    1. Re:Maybe I'm stupid by colinbrash · · Score: 1

      Or is this just a chance to write an article using the latest buzzword?

      Take AJAX a wild AJAX guess. AJAX.

    2. Re:Maybe I'm stupid by porneL · · Score: 1

      These are old security problems in new cooler, faster, better package.

      AJAX seems to be hidden and because of that is as deceptive to n00bs as <input type=hidden> is.

      Security by obscurity is no security at all.

    3. Re:Maybe I'm stupid by the+chao+goes+mu · · Score: 1

      If I had mod points I would mod you +5 interesting! Something about what you said just fascinates me!

      --
      Boys from the City. Not yet caught by the Whirlwind of Progress. Feed soda pop to the thirsty pigs.
  16. asynchronous? by Douglas+Simmons · · Score: 1

    what does the author mean using this word in this context? yes I looked it up

  17. Additional AJAX Security Resources by Anonymous Coward · · Score: 0
  18. Sequence numbering? For sure? by MasterC · · Score: 1

    A possible way of securing one's application is using some form of 'sequence-numbering'-like scheme.

    How is this not security through obscurity? The only difference between guessing this sequence number and guessing the session ID in a cookie is only that of duration, but one sniff on the wire and you got it.

    Overall, the hype on AJAX security stems from people not treating the AJAX requests any differently from non-AJAX requests. Trusting your input is mistake #1 regardless of where or how it comes.

    And we'll rehash this entire deal in a few years when AJAX is replaced with something else of equal buzzwordthyness.

    --
    :wq
  19. POST is more secure, WTF? by Anonymous Coward · · Score: 1

    He states POST is more secure because it is harder to fake?? Nice joke.

    1. Re:POST is more secure, WTF? by DahGhostfacedFiddlah · · Score: 1

      The only way I can see POST being more secure is that web-apps that display HTML content may strip out a lot of tags and javascript, but pass image/link urls through without validation.

      An image or link can't send information to a script that only accepts POSTs.

      Check out this link for more information.

  20. What? by cosinezero · · Score: 1

    What difference does asyncronicity make with security? Zero.

    What difference should AJAX make with security? Zero.

    All security should be applied on the server-side portion of your AJAX application. The same way any other web application is secured. End of question.

  21. Can someone explain...? by misleb · · Score: 1

    Could someone please explain to me how these potential problems with AJAX requests are unique to AJAX at all? This article did a horrible job at that. Couldn't any GET (to a script) or POST request request be "faked?" Aren't forms and links just as vulnerable to variable insertion and whatnot? AFAIK, there is really no fundamental different between an HTTP request made by a user directly and XmlHTTPRequest.

    -matthew

    --
    "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    1. Re:Can someone explain...? by Anonymous Coward · · Score: 0

      Because it's trivial to expose the guts of your api with AJAX, whereas GET and POST typically go through a single well-defined and secured interface. Most AJAX API's pay short shrift to security and don't even give you a decent way to secure their remoting interface.

      I guess that analysis just flew over the heads of all the knee-jerkers here.

    2. Re:Can someone explain...? by misleb · · Score: 1
      Because it's trivial to expose the guts of your api with AJAX, whereas GET and POST typically go through a single well-defined and secured interface.
      Really? Isn't the typical PHP application, for example, full of different interfaces? index.php, mailbox.php, submit_form.php, etc? Typical non-AJAX web apps rarely define a single point on entry.
      Most AJAX API's pay short shrift to security and don't even give you a decent way to secure their remoting interface.
      The only two AJAX APIs i've used extensively are JPSpan and Prototype/Ruby on Rails. JPSpan most certainly defines a single point of entry for ALL ajax requests, typically called server.php. And RoR treats AJAX requests as the same as any other request. So I have no idea what yo are talking about. And since you are an (anonymous) coward, I don't suspect I'll get an opportunity to find out either.

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
  22. Re:Sequence numbering? For sure? by DavidTC · · Score: 1

    Not to mention that someone can have a legit number, and still be doing what they're not supposed to be doing.

    --
    If corporations are people, aren't stockholders guilty of slavery?
  23. Enough with "Enough already" by Anonymous Coward · · Score: 0

    I am growing sick of hype surrounding the AJAX bandwagon.

    What, how is an article that talks about security vulns hype? Would you rather that information like this be "kept quiet"? I didn't see anywhere where AJAX itself was being hyped up, or that it was being claimed that it was superiour to anything else (aamof, quite the opposite, the author implies that there could be additional problems with this new beast).

    I understand where you're coming from, but pick a more appropriate article to post your rant on, this isn't it.

    1. Re:Enough with "Enough already" by Bogtha · · Score: 2, Insightful

      What, how is an article that talks about security vulns hype?

      It's hype because Ajax has absolutely no bearing whatsoever on the topic at hand. Web applications that don't use Ajax are just as vulnerable to these problems as web applications that do use Ajax, and the problems are solved in exactly the same way.

      Yet somehow, the submitter has managed to get a badly-written article that offers nothing novel whatsoever to the front page of Slashdot merely by arbitrarily inserting the latest buzzword as many times as possible.

      --
      Bogtha Bogtha Bogtha
    2. Re:Enough with "Enough already" by gregarican · · Score: 2, Insightful

      You hit the nail on the head regarding the source of my rant. The article is just cashing in on the craze and adds nothing of value to the broader subject of web app security as it applies to all of the non-AJAX world. The cashing in idea reminds me when I was a kid growing up in the 70's. When roller skating was popular all of these shows threw skating rink scenes into their episodes for no apparent reason just to cash in. Disco dancing obviously another sad, sad example too. Someone please mod me offtopic now :-)

    3. Re:Enough with "Enough already" by the+chao+goes+mu · · Score: 1

      You forgot the late 90's trend of adding "virtual" to everything. Or adding "e" to the begining of any word (which Apple morphed into adding "i" to everything).

      --
      Boys from the City. Not yet caught by the Whirlwind of Progress. Feed soda pop to the thirsty pigs.
  24. This is security advice? by arevos · · Score: 1

    This author of this article does not seem to properly comprehend security issues. He rambles on for several pages, but doesn't actually propose anything novel or indeed anything particularly useful.

    Using POST instead of GET and checking for User Agents and Referer headers won't do much to make your web application anymore secure. It's the web equivalent of hiding the keys under the doormat. Sure, it's better than leaving your door wide open, but it's not security in any meaningful sense of the word.

    The way to secure AJAX is the same way classic CGI transactions are secured; through sessions, passwords and SSL.

    1. Re:This is security advice? by possible · · Score: 2, Informative
      The way to secure AJAX is the same way classic CGI transactions are secured; through sessions, passwords and SSL.

      Did you even read the article? This is a new class of vulnerability. The risk is from the AJAX features in the browser. It allows malicious code on site A to cause things to happen on site B, as long as the user has a session established (in another window or tab) with site B. This attack works even if site A uses sessions, passwords, and SSL.

      Imagine this: you log into a secure webmail application by using HTTPS and entering a password. A randomly generated session ID is stored in a cookie on your browser. Now in another tab, you browse to evil.com, which has some AJAX JavaScript which causes your browser to send a complete, well-formed HTTP POST request (including session cookie) to your webmail application. The POST request changes your webmail password to a known value (chosen by evil.com). The webmail application designers followed all of your suggestions (HTTPS, passwords, and session IDs), yet some random site on the internet just changed your webmail password without you even knowing.

      Go read the Cross-site request forgery article on Wikipedia.

    2. Re:This is security advice? by makomk · · Score: 1

      Imagine this: you log into a secure webmail application by using HTTPS and entering a password. A randomly generated session ID is stored in a cookie on your browser. Now in another tab, you browse to evil.com, which has some AJAX JavaScript which causes your browser to send a complete, well-formed HTTP POST request (including session cookie) to your webmail application. The POST request changes your webmail password to a known value (chosen by evil.com). The webmail application designers followed all of your suggestions (HTTPS, passwords, and session IDs), yet some random site on the internet just changed your webmail password without you even knowing.

      Not quite right - AJAX (specifically, XmlHttpRequest) doesn't let you make requests to other domains. You actually have to use a normal form (optionally with some JavaScript to submit it) - which you could do before AJAX came along!

    3. Re:This is security advice? by arevos · · Score: 1
      Did you even read the article? This is a new class of vulnerability. The risk is from the AJAX features in the browser. It allows malicious code on site A to cause things to happen on site B, as long as the user has a session established (in another window or tab) with site B. This attack works even if site A uses sessions, passwords, and SSL.

      XMLHttpRequest can only send HTTP requests to the same domain from which it was invoked. Likewise, cookies can only be read from the domain from which they were invoked, and, surprise surprise, Javascript is limited to the domain from which it was invoked as well. A security vulnerability of the likes you describe would need a browser vulnerability in two separate systems. No such vulnerability is known to exist in any of the major browsers. In addition, I contend that browser vulnerabilities are not a website maintainer's responsibility.

  25. Tinfoil Response by 0110011001110101 · · Score: 4, Funny
    You sir, are a sucker. I have found a way to beat the dreaded AJAX Google Maps insecurities. Simply put, I have a new house built every couple of years. My current house will be done in a week or so, and according to Google Maps (evil AJAX house bombing helper) my new cul-de-sac does not even exist. It's just a lot of trees... now who would bomb trees?

    Please please please, buy a new house, or next time the Google Spyplane comes to take pictures, teepee your neighborhood with Tinfoil, I'm sure your neighbors will understand once you explain it to them.

    --
    Don't anthropomorphize computers: they hate that.
    1. Re:Tinfoil Response by the+chao+goes+mu · · Score: 1

      I have a better solution. I live under those trees! Dressed only in my tinfoil jumpsuit, hiding in dense foliage, no google spyplane will ever find me!

      --
      Boys from the City. Not yet caught by the Whirlwind of Progress. Feed soda pop to the thirsty pigs.
  26. without RTFA .... by cyclomedia · · Score: 1

    1. verify your data, i have a bunch of asp functions that each convert any input into a string/int/decimal/bool,date that return ""/0/0.0/false/(now) upon chocking on their inputs, simple

    2. use regular expressions, strip out the naugty chars from your inputs where you can, like newlines, even semicolons (no one i know has a semi colon in their name, date of birth or email address), and HTML encode your data BEFORE you try to save it to your db, gets rid of the double quotes AND saves time encoding it for every page write.

    3. generate unique ids. easy way: generate a long random number, and then add the date and time of the request to the end. sure the right hand half is somewhat guessable but it ensures uniqueness*, which is always handy.

    4. FFS dont assume that a user will only click links, anything that comes from the get or post needs double checking against the user's permissions. a lot of security flaws have been found this way: log in, view your bank account, change the url from viewuseraccount.asp?id=1234 to viewuseraccount.asp?1235 ... i'd expect to be fired for making it that simple

    5. dont have "website.com/admin/"

    6. dont use "UPDATE" or "INSERT" or "DELETE" querys

    7. etc.

    *nearly, unless you get slashdotted i suppose, then i expect your server will go down before the left (random) half also provides a collision anyway :-)

    --
    If you don't risk failure you don't risk success.
    1. Re:without RTFA .... by martinmarv · · Score: 1

      6. dont use "UPDATE" or "INSERT" or "DELETE" querys

      What do you mean? Only use stored procedures? You can safely use the above if you parameterise them (as long as the queries are on the server-side code, and not embedded in the javascript or something silly like that).

    2. Re:without RTFA .... by arevos · · Score: 1
      1. verify your data, i have a bunch of asp functions that each convert any input into a string/int/decimal/bool,date that return ""/0/0.0/false/(now) upon chocking on their inputs, simple

      I'm not too familiar with ASP, but wouldn't exceptions be a better choice instead of returning null input?

      The easiest way to validate input I've found, is to just grab a decent web framework with a validation system built in. There's plenty around.

      3. generate unique ids. easy way: generate a long random number, and then add the date and time of the request to the end. sure the right hand half is somewhat guessable but it ensures uniqueness*, which is always handy.

      Running the numbers through an MD5/SHA1 hash is also often used. But surely session handling is mostly automatic in this day and age? I can't remember the last time I had to think about manually constructing a session cookie and session ID.

      6. dont use "UPDATE" or "INSERT" or "DELETE" querys

      Eh? What do you mean by this?

    3. Re:without RTFA .... by Anonymous Coward · · Score: 0

      4. FFS dont assume that a user will only click links, anything that comes from the get or post needs double checking against the user's permissions. a lot of security flaws have been found this way: log in, view your bank account, change the url from viewuseraccount.asp?id=1234 to viewuseraccount.asp?1235 ... i'd expect to be fired for making it that simple

      I actually used to work at one web development agency, and one of the first things I had to do upon starting work there was fix about a dozen online shopping websites so that this wasn't a problem. What would happen was that the buyer would complete his transaction, and end up at something like /confirmation.asp?id=12345, which was a page (using SSL! Yay for security!) displaying the visitor's name, address, order details, and their full credit card details. Of course, any remotely observant visitor could simply decrement the ID number repeatedly to look at previous orders. But at least it was encrypted!

      These websites earned the agency tens of thousands of pounds each, but they were completely atrocious. Of course, the businesses hiring us had no idea how to evaluate security, so they got fleeced. I distinctly remember my boss telling a client who had a complaint about somebody not being able to use their website in Opera that he was a no-good hacker with too much time on his hands and should be ignored.

      I have my own business these days, and unfortunately, I still lose contracts to people like these, because clients simply don't believe that "respectable" agencies that have been going for a decade would churn out something as awful as they tend to do.

    4. Re:without RTFA .... by rjstanford · · Score: 1

      2. use regular expressions, strip out the naugty chars from your inputs where you can, like newlines, even semicolons (no one i know has a semi colon in their name, date of birth or email address), and HTML encode your data BEFORE you try to save it to your db, gets rid of the double quotes AND saves time encoding it for every page write.

      Well, yes and no. HTML encoding your data is really messy if you have to pass it off to other systems and you keep wondering if you've already decoded it, or not, or if you need to re-encode it - ick. Keep it native as long as possible and HTML encode it on the way out.

      But really, none of that should be necessary. Your app should never, ever, be creating a big long string of SQL. Its about the least efficient way to communicate with your database. Write all of your queries using bind variables (effectively placeholders for values, often a ? in the string). Prepare them once (some modern databases will correctly cache and pool them for you even if you skip this step) and execute them with the variables containing your data.

      Making all of your queries this way means that there's no, nada, zero chance of the content of one of those variables ever "infecting" your database, because the database knows at a fundamental level which information is instruction (your SQL command) and which information is data (contained in your variables). Doing anything else is asking for trouble, no matter how well you think you may have checked the data.

      So. Its faster, easier, and more secure. Its supported by every major database language layer that I know of. And its more "standards-compliant" to boot. Life is good, no?

      --
      You're special forces then? That's great! I just love your olympics!
  27. Stupid comment by brunes69 · · Score: 1

    ....as it's asychronous and a malicious user could write data back to your database if implemented incorrectly."

    The fact that it is asychronous has absolutely nothing at all to do with whether or not it has the ability to write back to the database.

    You can have AJAX calls that write to the database, and ones that don't, both being asychronous. Also you can have sychronous AJAX calls (is this just "JAX"???) that write to the database.

    Anyway - its pretty much the same considerations you should take when writing any web application. Verify all inputs, period.

  28. Re:Sequence numbering? For sure? by Bogtha · · Score: 3, Informative

    The only difference between guessing this sequence number and guessing the session ID in a cookie is only that of duration

    Not quite. The article does a horrible job in explaining it, but basically, one problem is that if an attacker can induce you to view a page containing JavaScript, that JavaScript can execute GET and POST requests under your authority.

    So, for example, if the attacker knows that you use Foo Webapp, then he can put up a page on his own site that executes requests corersponding to that web application, and send you a link saying "hey, look at this!" or whatever.

    Here's the thing - because it's your browser making the requests, and because those requests are going to Foo WebApp's domain, your browser will send your cookies along with the request, proving that it's you.

    What this means is that you not only have to prove that it's you making the request, you also have to prove that it's a request you meant to make. User authentication alone is not enough.

    The typical solution to this is to additionally include another random cookie-type value as a hidden field in every form you generate. Because your attacker doesn't have access to the pages you are viewing, he won't have access to that value, so he can't construct forms that submit that value to Foo WebApp. In this way, you can reliably determine that it's a valid form submission that comes from your own web application.

    None of this, of course, is dependent upon Ajax being used. Ajax is a red herring here. This security concern applies to all web applications, whether or not they use Ajax.

    --
    Bogtha Bogtha Bogtha
  29. AJAX STDs cleaning by Anonymous Coward · · Score: 0

    So, does that mean if I use more control of the use of my AJAX that I'll get less infections or reduce the chance of getting the clap?

  30. TraficShield by Anonymous Coward · · Score: 0

    http://www.f5.com/products/TrafficShield/

    App Security

    TrafficShield® is a web application firewall that provides comprehensive, proactive, network and application-layer protection from generalized and targeted attacks by understanding the user interaction with the application firewall. TrafficShield employs a positive security model ('deny all unless allowed') to permit only valid and authorized application transactions, while automatically protecting critical web applications from attacks such as Google hacking, cross-site scripting, and parameter tampering.

  31. Network security 101 by Aceticon · · Score: 3, Informative

    If a functionality is remotelly available via a public network then anybody can try to hack into your system via it.

    Without AJAX: A web application serves pages via single HTTP calls, possibly with one or more parameters, per page.
    - Hackers can try getting into your system via this web application by tweaking the parameters, URL, HTTP headers, etc of the requests used to retrive pages

    With AJAX: A web application serves pages via a single HTTP call, possible with one or more parameters, per page. Additionaly, JavaScript embedded in the page will, typically in response to user input, send extra HTTP requests to get more information (mostly in XML or plain text format).
    - Hackers can try getting into your system via this web application by tweaking the parameters, URL, HTTP headers, etc of the requests used to retrive pages or extra information.

    Same principle for both, it's just that with AJAX there is a bigger number of entry points (more "handlers" for HTTP requests) since asynchronous HTTP requests from the Javascript code also require server-side code to process those requests (and generate responses).

    Can you trust that nobody will try to get into your system by hand-executing an HTTP Request to a request handler that's supposed to only be called by Javascript code? Of course not!

    It's the same reason why when an HTTP form is submited to the server you still check (on the server side) the validity of the information submited for that form even though your Javascript validator also does a full validation of the form before allowing the user to submit it.

    Programmers that don't implement checks on information submited to the server and/or feed it directly to interpreted language engines (such as SQL query executers) without escaping or protecting it (in some other way) will ALWAYS leave gaping security holes open, AJAX or no AJAX.

    An incompetent programmer is always an incompetent programmer.

  32. Use Fiddler for this analysis by Anonymous Coward · · Score: 0

    If you're going to investigate this, try using Fiddler (http://www.fiddlertool.com/). It's pretty much incredible, though it is Windows-only. It's .NET so maybe it could get Mono-ized without too much trouble.

    Capcha: "unparsed" :)

  33. buzzword wins, flawless victory by Flunitrazepam · · Score: 1

    In Mortal Kombat 2, A JAX fatility showed a large African American man rip the arms off his enemy.

    --
    1) Your analysis is based on bad assumptions so your result is way off. 2) You're a sick bastard for fucking a horse.
  34. "AJAX" alternative? by greywire · · Score: 2, Interesting

    Can somebody please come up with a name other than AJAX? I find myself talking about the programming techniques covered by the moniker of "AJAX" (herein after refered to as "BLURG") and wanting to call it something other than "AJAX":

    BLURG is not necessarily asynchronous: you may be updating only a small part of the page, but doing it synchronously.

    BLURG does not require XML. In fact you could be returning HTML, Javascript, CSV, JSON, etc.

    BLURG does not even require the XmlHttpRequest feature and BLURG techniques have been in use far before the existance of this feature.

    Can we please come up with a better name for BLURG, one that covers the more general programing techniques involved? Something for us people to use that is NOT just the trendy new thing known as AJAX? Something that we can use that will let others like us know that we have been aware of these techniques even before the term AJAX was coined?

    For now I will call it BLURG...

    --
    -- Senior Software Engineer, Attorney appearance services, locallawyerapp.com.
    1. Re:"AJAX" alternative? by merreborn · · Score: 1

      I find myself talking about the programming techniques covered by the moniker of "AJAX" (herein after refered to as "BLURG") and wanting to call it something other than "AJAX":

      Good luck. I've been asking for years what the Fi in WiFi means. Wireless Fidelity? What the hell does that mean?

      Someone suggested "Wireless Frequency" which is even stupider, as there is no one "Wireless Frequency" (not even amoung the 802.11 standards) -- not to mention the fact that it's an unused term ...and I don't know how "Frequency" shortens to "Fi".

      I suggested WiNet, as in WIreless NETworking. Haven't gotten any takers yet.

    2. Re:"AJAX" alternative? by the+chao+goes+mu · · Score: 1

      How about "JavaScript Kludge, Now With XML!"?

      --
      Boys from the City. Not yet caught by the Whirlwind of Progress. Feed soda pop to the thirsty pigs.
    3. Re:"AJAX" alternative? by jalefkowit · · Score: 1

      Personally, I refer to it as 20 Mule Team BORAX (Bidirectional Object Reuse Atop XML).

      20 Mule Team BORAX. Accept no substitutes!

    4. Re:"AJAX" alternative? by screaser · · Score: 2, Interesting

      I've read and believe that AJAX is being or has been de-acronym-ified...

      AJAX is just a proper noun now, referring more to the user interaction style used in the BLURG apps you mention, and doesn't need to use any specific technology.

      i.e. Don't shove the whole user interface down the pipe every time the user clicks... adapt the interface as work progresses... etc.

      The term is probably here to stay... so we might as well make it mean what we want it to.

    5. Re:"AJAX" alternative? by Dan+East · · Score: 1

      How about Web 2.0?

      Dan East

      --
      Better known as 318230.
    6. Re:"AJAX" alternative? by conteXXt · · Score: 1

      Well done.

      I am sure this SHOULD be the new name.

      When I was a kid there was a powdered soap called Boraxo (a quick check later and it appears to still exist).

      Great stuff.

      --
      The truth about Led Zep should never be told on /. (Karma suicide ensues)
    7. Re:"AJAX" alternative? by greywire · · Score: 1
      Good luck. I've been asking for years what the Fi in WiFi means. Wireless Fidelity? What the hell does that mean?
      That's definately another one. I hate saying WiFi, but these days its what people understand. If you say 802.11 you get a blank stare. If you say wireless, they dont know if you mean cell phone, bluetooth, RC Cars, or what...
      --
      -- Senior Software Engineer, Attorney appearance services, locallawyerapp.com.
    8. Re:"AJAX" alternative? by greywire · · Score: 1

      Web 2.0: We Are Finaly Understanding The Internet (WAFUTI).

      Not quite as cute a name, but, WAFUTI is pronouncable.. :)

      --
      -- Senior Software Engineer, Attorney appearance services, locallawyerapp.com.
  35. Who else does this right by Beryllium+Sphere(tm) · · Score: 2, Informative

    Microsoft ASP.NET version 2 also fights cross-site request forgeries with a MAC'ed token:
    ViewState, ViewStateUserKey, andother ASP.NET security-related features

    To save you futile Googling, be aware that Microsoft refers to cross-site request forgery as "one-click attacks".

    Don't underestimate how important this attack is. To quote The PHP Consultancy, The most challenging characteristic of CSRF attacks is that the legitimate user is essentially making the request. Thus, regardless of how perfect the user identification and/or session management mechanism is, a CSRF attack can still be successful."

  36. Cross site request forgery by possible · · Score: 2, Informative

    It seems that the author is unaware of all the research that has already been done in this area. This type of attack is known as Cross-site request forgery and the counter-measures (which the author re-derives from first principles in his article) are already known.

  37. Most secure AJAX app evah by suv4x4 · · Score: 1

    - JavaScript is used to create an SQL query based on what report the user wants.
    - This SQL string is submitted in a form and executed as an SQL query directly without any checks or anything.
    - The db user executing the query has enough rights to read / edit / delete all databases on the server.
    - Everything the query returns is serialised and passed back to JavaScript to parse and display.

    That's an actual case in an actual web application, though the guy had long experience with SQL he was new with AJAX apps, so we caught that in the code audit.

    Now he knows that's a Really Bad Idea to do, I wonder how many boys and girls out there don't.

    1. Re:Most secure AJAX app evah by Anonymous Coward · · Score: 0

      holy crap.. why is this moron still employed?

    2. Re:Most secure AJAX app evah by suv4x4 · · Score: 1

      I know how it sounds but the guys is pretty good with SQL queries. He can write whole huge queries that get the required data in one pass and much faster than in multiple queries and processing in PHP as the rest of us would do.

      He never really worked or understood AJAX so we had to cut him some slack.. But ya, he's not doing the JS anymore ;)

  38. semantics of GET and POST by pikine · · Score: 4, Insightful

    Your remark really concludes this topic, and I think any further remarks are redundant. I just want to point out that in the HTTP specification (RFC 2616) section 13.9, it says the following about GET requests:

    Unless the origin server explicitly prohibits the caching of their responses, the application of GET and HEAD methods to any resources SHOULD NOT have side effects that would lead to erroneous behavior if these responses are taken from a cache.

    And in section 9.5, about POST requests:

    Responses to this method are not cacheable, unless the response includes appropriate Cache-Control or Expires header fields.

    Thus, the only semantic difference between GET and POST is only on side effects. There is no sense in saying one is more secure than another, or one is easier to fake than another.

    If we think of a web server as a function, GET requests means that, let y1 = f(x1) and y2 = f(x2), then x1 = x2 implies y1 = y2. POST requests means there exists y1 and y2, y1 != y2, such that y1 = f(x) and y2 = f(x) for some two applications of f with x. Here y, y1 and y2 are the "web pages" (more generally, resources), and x1, x2, x are the HTTP requests.

    Of course, for a practical, dynamic website, the functional property does not usually hold, and that's why we have "cahce control", which attempts to establish what functional property holds under certain conditions.

    --
    I once had a signature.
    1. Re:semantics of GET and POST by stromthurman · · Score: 1

      Very well said. I particularly like the view of GET and POST as functions, but then I am a mathematician, at least in title.

      --
      I have discovered a truly remarkable sig which this margin is too small to contain.
    2. Re:semantics of GET and POST by rowama · · Score: 1

      I believe you could have simply stated that GET should be idempotent and POST doesn't have to be. KISS.

    3. Re:semantics of GET and POST by pikine · · Score: 1

      I believe you could have simply stated that GET should be idempotent and POST doesn't have to be. KISS.

      It's not obvious for me at first thought how idempotence, e.g., A AND A = A in classical logic, is related to side effects, but it is interesting to note that Linear Logic, where none of the logical operators are idempotent, can be used to keep track of states. From there, we can go back to your remark saying GET should be idempotent (hence stateless) and POST doesn't have to be (hence stateful).

      I guess you either jumped to the conclusion, which is indeed elegant, or you've implicitly worked out the details, which is not so simple IMHO.

      --
      I once had a signature.
    4. Re:semantics of GET and POST by rowama · · Score: 1

      Good point. Not being a heavy math type, I jumped straight to a CS understanding of idempotence. It is simpler: given the same input, repeatedly, a function's output will not change. Obviously, side-effects must be considered part of the output for this to hold.

  39. Easiness Mostly by Serapth · · Score: 1

    Well, one difference I can think of is ease of use... or ease of abuse. With POST/GET, especially POST you have a fair bit more work. You need to setup a fake POST form that circumvents whatever security they might have in place, whatever.

    With AJAX though, you can just view source of this existing page, then in the URL bar, start trying various combinations out, such as javascript://SomeAjaxFunction(someVar); enter. Repeat and rinse. Hell, you could do an inline breakpoint, and use your favorite client side js debugger to try new exploits.

    In the end, not a big difference, except in the ajax way, you already inhereited an client side security tokens or whatever else that the page may be using for security. You are pretty much injecting your code on the fly into whatever the origonal author wrote. Whereas in POST manipulation, you are basically trying to emulate a client request from beginning to end.

  40. The same thing... by C10H14N2 · · Score: 1

    ...everyone else concerned with the topic means by it:

    http://en.wikipedia.org/wiki/AJAX

  41. I'm pretty sure... by Netsnipe · · Score: 1
    ...that my AJAX-based Slashdot posting console is secure.

    But most of all, samy is my hero.

    --
    -- "I can't tell the future, I just work there." -- The Doctor
  42. all of my servlets by josepha48 · · Score: 1

    .. check for the session to be correct.. in other words, a user must login first and that login is stored in the session. so any of my servlets that actually talk to my database need that login first, as they ALL check the session. You can't just post the form to do an update in my system, you must have other data in order for that post to actually pass step 1. This is IN every servlet.

    --

    Only 'flamers' flame!
    Does slashdot hate my posts?

  43. AJAX like all JS should be supplimental at best by Hohlraum · · Score: 1

    We design applications so that they function entirely with JS disabled. All data that is validated on the front end is re-validated on the backend along with session state verification. If you aren't doing this you are going to get what you deserve in the end.

  44. depends on which 'side' you are on by thoughtlover · · Score: 1

    "...and a malicious user could write data back to your database if implemented incorrectly."

    Isn't that supposed to be, "...if implemented correctly"

    --
    No sig for you! Come back one year!
  45. Validation by jabberwocky_rt · · Score: 1

    Always validate what you run through eval()!

    While not fool proof, making sure that what you got back from the server is JSON, and not a string of malicious code is paramount.

    And guess what, such things already exist.

    Granted, this doesn't prevent someone from embedding that same malicious code in valid object code that appears identical to what you expect as a server result, but its a huge step in the right direction.

  46. ny by Pieroxy · · Score: 3, Insightful

    I feel like I am entering the twilight zone...

    This is an issue that has not changed one bit since the dawn of the web: Everything that comes in your server through an HTTP(S) request is to be assumed 'insecure' by definition. The only assumption one can make about such data is that it comes from a specific user if a proper session id is provided, nothing else.

    This is a very very very common misconception in almost every application I have worked on. People (devs) seems all to think that a javascript consistency check is all it takes to ensure the user will not submit an amount too high, or anything else for that matter.

    The approach is flawed because of one thing: Everything that runs out of your box can be fooled with. And JavaScript is so easy to fool with that it is a shame that ANYONE would rely on any piece of JavaScript without any security/safety check on the server side.

    AJAX is just another extension based on the same principle. Anyone can fool an HTTP request. Anyone can fool a Browser. Anyone can execute arbitrary Javascript code in your browser to modify its behavior: Just type the code in the address bar.

    This issue is just insane!

    Is Your AJAX App Secure?: As secure as any webapp. Consistency and security checks needs to be made on every data coming in your system. Short of that, it is just swiss cheese: Full of holes.

    1. Re:ny by ShieldW0lf · · Score: 1

      The problem I see with AJAX is that IE doesn't reliably pass the session cookie from the browser session when it creates a XmlHttpRequest; sometimes it creates a new session instead of maintaining the old one. So if you're using sessions to create a secure user experience, you can't secure anything you interact with using AJAX. I personally find it a real pain in the ass.

      --
      -1 Uncomfortable Truth
    2. Re:ny by stunt_penguin · · Score: 1

      Sorry, by 'you pass your request into your pre-written function which has any request-related security processes written into it' I did mean server-side because of course, yes, anything that comes out of your box can be monkeyed with and you can only really, really validate input security-wise on the server side. Heh, I shoulda been clearer :o)

      --
      When the posters fear their moderators, there is tyranny; when the moderators fears the posters, there is liberty.
  47. Article fails to address the issue ... by Anonymous Coward · · Score: 0

    All controls being mentioned in the article are useless and do not address any issues with Ajax or any HTTP based technology (User-Agent, Referrer, ID's, etc are clinet controllabe)....

    PS: Check out an HTTP proxy for your good...

  48. Quote by Polly_Morf · · Score: 0

    Just thought of a quote by Thomas Brattli (a real DHTML-guru):

    Let's keep DHTML alive and say bollocks to AJAX!

    Even if I don't share his opinions, I strongly advise you to chech his site http://www.dhtmlcentral.com/. He has done some amazing things.

    Sorry for the grammar, I'm swedish. Bork! Bork!

  49. MOD PARENT DOWN! by Anonymous Coward · · Score: 2, Informative

    By reading your comments, anyone who has a clue can tell you're definitely a n00b at this. Things like HTML encoding your stuff before committing to DB lets us guess you're concatenating strings - the best way to be vulnerable to SQL injection attacks. Rather bad advice. If you were using parameters (parameterized queries or sprocs) none of this would be necessary. And even though one should strip off nasties from inputs, it becomes less critical that your stripping is 100% bullet proof (it'll never be).

    #6 is just plain stupid. Might as well say "don't use databases". Things like that are required hundreds of times per second in thousands of every production systems. Somehow data HAS to change. And since you're concatenating to generate your queries, you're still more vulnerable to problems than someone using parameters properly - once a flaw is found in your "protection" (that often rely on things like blindly doubling single quotes and such), they can easily tack on a DROP TABLE at the end if they want to, whereas with parameters (again, used properly) it's quite safe to use INSERT/UPDATE/DELETE. (Not to mention, non-web apps will have to needlessly HTML decode stuff to display it when it's completely unecessary). Validating for proper user input (sever side req'd, client side as well preferably) is a must - just removing bad chars (like getting rid of double quotes) is NOT a good way to do this, and it'll often end up just crippling perfectly valid entries you hadn't expected.

    #5 is nonsense. It does NOT matter what it's called. It just has to be secured properly. Or perhaps you're recommending security by obscurity - hopefully they don't ever guess or find out the admin page's directory name or else... I've never had a security problem with my admin pages, even if I put a direct link to them that's accessible to pretty much everybody. As long as they're secured properly it's a non issue. All they'll ever see in an "admin login page".

    Honestly, you're NOWHERE near enough knowledgeable to give advice on how to secure apps. Lots of it is plain wrong, some of it is just a hack or workaround the real problem, and no real problem solving / peroper way to do it. You don't want others to use that, you're essentially doing them a disservice by giving them this wrong info. There's tons of great guides on the web that'll teach 'em all the good stuff that they should be reading instead (and perhaps you too). You still have TONS to learn. This isn't even the tip of the iceberg.

    1. Re:MOD PARENT DOWN! by cyclomedia · · Score: 1

      i dont concat SQL strings. usually i'd apply an alphanum+spaces+couple_other_chars regexp filter to an input anyway, which happens to have the effect of removing semi colons. and if you're not using string concatation then you're not building INSERT queries are you.

      --
      If you don't risk failure you don't risk success.
    2. Re:MOD PARENT DOWN! by Anonymous Coward · · Score: 0
      No, it is more likely that he's using prepared queries or something similar..

      If you use PostgreSQL, you can use the pg_query_param() function to build queries:

      Eg. in PHP:
      pg_query_param("INSERT INTO $1 (id, foo, bar) VALUES ($2, $3, $4)",
        array("tablename", 123, "foo value", "bar value"));
      or create a prepared query:
      pg_prepare("mystatement", "INSERT INTO mytable (id, foo) VALUES ($1, $2)");
      then call it as:
      pg_execute($conn, "mystatement", array(123, "foo value';$2\"---zzzz"));
      Both are 100% safe from any kind of SQL-injection attacks.
    3. Re:MOD PARENT DOWN! by jbplou · · Score: 1

      Use stored procedures and you won't care if semi-colons are inserted, they won't hurt the statement. Plus you'll get a performance boost to boot. Use of stored procedures have so many advantages over dynamic SQL, you really are quite novice to not realize this.

  50. I have to say, stupid stupid stupid by tod_miller · · Score: 1

    Browser.... request .... security .... application
    Browser.... asynch request .... security .... application

    erm, questions?

    The point has nothing to do with 'asynch' but more to do with programmers think that the average user cannot produce requests to these server objects easily, despite being simple http calls...

    so there. all bollocks.

    --
    #hostfile 0.0.0.0 primidi.com 0.0.0.0 www.primidi.com 0.0.0.0 radio.weblogs.com
  51. Well, POST is more secure by RedLaggedTeut · · Score: 1

    At first I thought it doesn't matter whether you use GET or POST, but he has a point with the image tag, because you can more often sneak a GET request into an im src attribute than a POST.

    A second reason as pointed out by pikine is that all GET requests are supposed to be idempotent, as in, they perform operations which do no major changes to the basic data of the hosted application. For example, many wiki authors complained about rogue bots deleting their content when the bots actually were only following GET requests.

    Well, my complaint about the article would be that the this also affects non-Ajax apps. Maybe it would be different if Ajax was using its own access method but POST and GET.

    --
    I'm still trying to figure out what people mean by 'social skills' here.
    1. Re:Well, POST is more secure by stromthurman · · Score: 1

      Yes, a GET request can be put into the src of an img tag, but that doesn't make POST more secure. A proper web-app should use GET requests for fetching data, and POST for modifying data. However, all requests should be validated on the server-side. If an unprivileged client can follow a GET request that deletes content, then the web-app is not performing proper validation. If that's the case, hiding the request behind a POST is not going to stop a malicious attacker from deleting content. This was my original point, if you're not validating a request, POST or GET, then using POST instead of GET is a pretty weak measure of "securing" anything.

      --
      I have discovered a truly remarkable sig which this margin is too small to contain.
    2. Re:Well, POST is more secure by RedLaggedTeut · · Score: 1

      Well, my point is that if your web application uses Cookies as a method to grant yaccess privileges, then it is more likely that it is possible to inject an image link that is actually a request. I am talking from the land of imperfect applications here, if you had a perfect application, you would probably not have an XSS opportunity in image links, and you would us your methods you cooked up yourself like sequence numbers to order and secure our requests.

      --
      I'm still trying to figure out what people mean by 'social skills' here.
  52. Javascript makes AJAX inherently unsafe by billstewart · · Score: 1
    It's important to make sure your AJAX code is well written, and maybe using SSL with it can help protect your code as well. But the big security problem is that if you're running AJAX, your user has to turn on Javascript in their browser, so if they view a web page that's written by somebody malicious and haven't turned Javascript back off first, they're toast. There are Firefox extensions that let you enable/disable Javascript on a per-site basis, and IE has some similar features, but if your users aren't forced to use them, they're probably running wide open.

    As far as _your_ applications go, your server does need to validate any input it gets and only accept correctly-formatted content. Your client should too, but if your server gets cracked then everybody who uses it is at risk. There's very little news there about AJAX that wasn't obvious 30 years ago when my college professors were telling their classes to assume that all input is potentialy malicious and malformatted and testing our homework projects to see what they did if fed bogus data - you still have to defend against that.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  53. It Happens by Anonymous Coward · · Score: 0

    I recently was messing around with a program that a friend of mine had main. He had made wrapper functions for all 21 of his ajax functions which made it a matter of changing the relative URLs to absolutes and I was in. I could run any ajax function including giving myself an administrator account. Not being the malicious type, I emailed him and detailed how to fix the vulnerability (include the md5 of the password with all function calls), but I could have potentially done anything. Its my guess that there are thousands of these unsecure applications all over the internet.

  54. Re:Sequence numbering? For sure? by JahToasted · · Score: 1

    I was under the impression that xmlhttdrequest won't allow you to access any domains other than the one the page was loaded from. So javascript loaded from example.com can't request stuff from foo.org.

  55. Re:Sequence numbering? For sure? by Bogtha · · Score: 1

    Once more, this has nothing to do with Ajax, XMLHttpRequest, or anything like that. That was just something the article author added to get people reading. For POST requests, you just need the plain old JavaScript load event to submit a form, and for GET requests, you don't even need that. For example, this submits a GET request to delete something:

    <img src="http://www.example.com/foowebapp/delete-stuff .php?id=12345">

    ...and this submits a POST request to delete something:

    <body onload="document.getElementById('theform').submit( );">
    <iframe name="theframe" style="display:none"></iframe>
    <form id="theform" target="theframe" action=http://www.example.com/foowebapp/delete-stu ff.php" method="post" style="display:none">
    <input type="hidden" name="id" value="12345"></form>

    Both of these requests will be coming from your browser, your IP address, with your cookies, to the FooWebApp domain, no matter where the malicious code itself is hosted.

    In the first case you shouldn't be using GET to perform unsafe actions, and in the second case, you should include a random secret token in each legitimate form that you check for upon submission. Unfortunately, there are a hell of a lot of web applications out there that don't bother, leaving themselves wide open to attack.

    --
    Bogtha Bogtha Bogtha
  56. code to learn, right. by Sithgunner · · Score: 1

    The only decent thing said in the article is right below the big 'darknet.org.uk' logo.
    I totally agree about that.

  57. I dont have a house! by Anonymous Coward · · Score: 0

    You insensitive clod!