Allowing users to use html, what to look out for?

Discussion in 'Site & Server Administration' started by Pinoguin, Nov 1, 2008.

  1. #1
    In this CMS, Each user can have access to insert html to pages. But I can restrict each tag that pose a security threat.

    Aside from < script > what other tags should I take out?
     
    Pinoguin, Nov 1, 2008 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    <iframe> could coz problems too
     
    Bohra, Nov 1, 2008 IP
  3. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #3
    There's a lot of tags. Leaving a <noscript>, <textarea> or <style> tag open (these are a few of many) will remove the rest of the page. If I remember correctly, you can also have <img onload="javascript:badcode;"> - or just use a <body> tag. The options are endless.

    Jay
     
    jayshah, Nov 1, 2008 IP
  4. googleminigames.com

    googleminigames.com Banned

    Messages:
    1,335
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <noscript> <input> <big> << If they Use To Much They can mess up the whole page.. <textarea> and Some Marquee Codes Too

    BTW , Iframes are the Worst =/
     
    googleminigames.com, Nov 1, 2008 IP
  5. RectangleMan

    RectangleMan Notable Member

    Messages:
    2,825
    Likes Received:
    132
    Best Answers:
    0
    Trophy Points:
    210
    #5
    You should also clean img tags too. Most tags should be cleaned and that's why allowing html is a bad idea. Better to create bbcode for your site.
     
    RectangleMan, Nov 1, 2008 IP
  6. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Plain <img> tags can be exploited even without JavaScript.

    For instance, if someone put an image in a forum that looked like this:

    <img src="/logout.php" />

    It would successfully log out anybody who viewed that page.

    The easiest way to handle this might be to use the Pear BBCode extension and allow your users to use BBCode.
     
    Ladadadada, Nov 1, 2008 IP
  7. Pinoguin

    Pinoguin Peon

    Messages:
    848
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #7
    hmm... that's a lot.. even img tags, I have no choice but to take out the html editor then..

    Thanks!
     
    Pinoguin, Nov 2, 2008 IP
  8. keyaa

    keyaa Peon

    Messages:
    137
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I wouldn't recommend allowing HTML. Allow BBCode if you must and know what you're doing, nothing more.

    If you really really allow HTML - don't do a blacklist but a whitelist approach. E.g. don't filter out everything you consider harmful but only allow basic tags that you consider harmless. There's just too many ways out there to trigger the execution of potentially malicious JavaScript that you wouldn't even remotely think of, ever.

    Just a quick example to make my point: did you know the <marquee> tag has an onbounce event handler when it has it's behavior attribute set to alternate? (IE) .. Didn't think so. ;)
     
    keyaa, Nov 2, 2008 IP