How to Sanitize HTML (Javascript Security)
September 3, 2007 9:34 AM
Subscribe
Is there a safe way to sanitize user submitted HTML to prevent security problems?
I'm working on a website where users can post their own HTML. I want to be as flexible as possible in what I allow. I'm ok with removing Javascript from their HTML though.
So I guess A.) How do I accurately remove javascript? and B.) Are there any other security risks not related to javascript?
For part A. I'm thinking to not allow the script tag, and perhaps not allow onclick. I'm sure I'm missing stuff though.
By the way, the only security risk I've heard of for allowing untrusted Javascript on your site is that user names and passwords can be stolen, and other actions can be done on your site in the name of that user. Is there more to it?
posted by GregX3 to computers & internet (31 comments total)
9 users marked this as a favorite
Untrusted Javascript can deliver browser infections.
If you really want to be safe, you permit bold, italics, underlines and line breaks and nothing else whatever.
posted by Steven C. Den Beste at 9:49 AM on September 3, 2007