WebApp Sec mailing list archives
RE: Preventing cross site scripting
From: "Michael Howard" <mikehow () microsoft com>
Date: Thu, 19 Jun 2003 21:19:34 -0700
You can never know all the 'unacceptible' tags and the escape versions etc.. Why not simple define the list of 'acceptible' tags, look for those, and anything you don't like you whitespace. Simple and safe! The worst your gonna get is an annoyed customer that thinks you screwed them on what they consider is valid. Better that than a bunch of REALLY annoyed customers who think your stuff is unsafe! Cheers, Michael Writing Secure Code 2nd Edition http://www.microsoft.com/mspress/books/5957.asp -----Original Message----- From: David Cameron [mailto:dcameron () itis-now com] Sent: Thursday, June 19, 2003 6:51 PM To: Andrew Beverley; webappsec () securityfocus com Subject: RE: Preventing cross site scripting Create a list of unacceptable tags in an array (eg applet, embed), loop through the array and generate a regexpr based on the array, something of the form: <(applet)|(embed).?> and replace all instances with "". Do the same for any possible closing tags ie: </(applet)|(embed)> and replace all instances with "". BTW the RegExpr may be wrong, I'm not all that hot on RegExprs, but you get the idea. regards David Cameron nOw.b2b dcameron () itis-now com
-----Original Message----- From: Andrew Beverley [mailto:mail () andybev com] Sent: Friday, 20 June 2003 4:28 AM To: webappsec () securityfocus com Subject: Preventing cross site scripting I am currently writing a web application that, as a small part of it, needs to display an email message. Obviously the message is potentially in html format, which to display could be sent straight to
the browser. I would like to know the best way of filtering out undesirable html. I
understand the best way is to only allow acceptable information, in this case all the different html formatting tags. However, there is a lot of tags that are acceptable. Another approach would be to strip out all the bad stuff such as <SCRIPT>, <OBJECT>, <APPLET>, and <EMBED> but this is far from ideal because of new tags becoming available and so on. Are there any functions available (for php) that will take a html page
as input and strip out all nasty stuff? Does anyone have suggestions as to how to do this as easy as possible? Thanks, Andrew Beverley
Current thread:
- RE: Preventing cross site scripting, (continued)
- RE: Preventing cross site scripting Jeremiah Grossman (Jun 19)
- Re: Preventing cross site scripting Tim Greer (Jun 19)
- Re: Preventing cross site scripting Bob Lee (Jun 19)
- Re: Preventing cross site scripting Tim Greer (Jun 19)
- RE: Preventing cross site scripting David Cameron (Jun 19)
- Re: Preventing cross site scripting Tim Greer (Jun 19)
- RE: Preventing cross site scripting Jeremiah Grossman (Jun 19)
- Re: Preventing cross site scripting Tim Greer (Jun 20)
- RE: Preventing cross site scripting Mutellip Ablimit (Jun 20)
- Re: Preventing cross site scripting Tim Greer (Jun 20)
- Re: Preventing cross site scripting Tim Greer (Jun 20)