SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: Is this vulnerable to XSS?

  1. #1
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is this vulnerable to XSS?

    Hello,

    Say you have some javascript code where a user enters something in a field and that something, using the DOM, is entered directly into the page.

    Could this be used for any kind of attack?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    14,430
    Mentioned
    74 Post(s)
    Tagged
    1 Thread(s)

    Xss

    Try entering
    HTML Code:
    <sc
    ript>alert('XSS');
    </scri
    pt>
    into a field. Does an XSS alert box show?

    If "No", then the answer is maybe.

  3. #3
    Unobtrusively zen silver trophybronze trophy
    SitePoint Award Recipient paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,233
    Mentioned
    42 Post(s)
    Tagged
    2 Thread(s)
    To riff from the 10 immutable laws of security, when you place untrusted data directly into the web page, it is not your web page anymore.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mittineague, that wouldn't show an alert, because that javascript should run onload, and when a user would enter such thing into the field the page would be loaded already.

    But of course there would be other ways to make some javascript run on his own browser in that page, in the same way I can edit this page with firebug and make it do the exact same things.

  5. #5
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe I should clarify somehting. When I am saying "using the DOM, is entered directly into the page" I mean his own "instance" of the page which he has downloaded on his browser. Nothing is send back to the server.

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    14,430
    Mentioned
    74 Post(s)
    Tagged
    1 Thread(s)

    no alert

    So you tried it and didn't get an alert, or are you so convinced it won't you didn't try?
    As long as your site doesn't use cookies or require a login, and isn't saving the input in a file or database, then the site should be relatively safe (I guess). But IMHO it's better to not take chances or develop bad habits.

  7. #7
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried it but I wrote everything in one line because the input field is a single line input field.

    The site uses cookies but not for anything critical. The only one who has a login is myself.

  8. #8
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    14,430
    Mentioned
    74 Post(s)
    Tagged
    1 Thread(s)

    cookies

    In that case, AFAIK, then if someone put XSS script into a page and left the computer, then the next person would only risk having non-critical information sent out. Or maybe a chance that a "click here" bait link might be clicked.

  9. #9
    Unobtrusively zen silver trophybronze trophy
    SitePoint Award Recipient paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,233
    Mentioned
    42 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Zoom123 View Post
    I tried it but I wrote everything in one line because the input field is a single line input field.

    The site uses cookies but not for anything critical. The only one who has a login is myself.
    If that login is achieved through the web page then you are in danger.
    It can be trivial for people to use code injection techniques to get through.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #10
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anybody can insert anything in to the DOM in any page they are viewing.

  11. #11
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anybody can insert anything in to the DOM in any page they are viewing.
    Ain't that the truth!

    If you're using a public computer that's displaying the logon page for something you use when you get there - reload that page!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •