<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: How to Sanitize HTML (Javascript Security)</title>
	<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security/</link>
	<description>Comments on Ask MetaFilter post How to Sanitize HTML (Javascript Security)</description>
	<pubDate>Mon, 03 Sep 2007 09:49:01 -0800</pubDate>
	<lastBuildDate>Mon, 03 Sep 2007 09:49:01 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: How to Sanitize HTML (Javascript Security)</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security</link>	
		<description>Is there a safe way to sanitize user submitted HTML to prevent security problems? &lt;br /&gt;&lt;br /&gt; I&apos;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&apos;m ok with removing Javascript from their HTML though.  &lt;br&gt;
&lt;br&gt;
So I guess A.) How do I accurately remove javascript?  and B.) Are there any other security risks not related to javascript?&lt;br&gt;
&lt;br&gt;
For part A. I&apos;m thinking to not allow the script tag, and perhaps not allow onclick.  I&apos;m sure I&apos;m missing stuff though.&lt;br&gt;
&lt;br&gt;
By the way, the only security risk I&apos;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?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2007:site.70682</guid>
		<pubDate>Mon, 03 Sep 2007 09:34:44 -0800</pubDate>
		<dc:creator>GregX3</dc:creator>
		
			<category>javascript</category>
		
			<category>security</category>
		
			<category>xss</category>
		
			<category>html</category>
		
	</item> <item>
		<title>By: Steven C. Den Beste</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054409</link>	
		<description>Untrusted Javascript can be used to redirect users to another server which pretends to present the same page as yours does.&lt;br&gt;
&lt;br&gt;
Untrusted Javascript can deliver browser infections.&lt;br&gt;
&lt;br&gt;
If you really want to be safe, you permit bold, italics, underlines and line breaks and &lt;i&gt;nothing else whatever.&lt;/i&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054409</guid>
		<pubDate>Mon, 03 Sep 2007 09:49:01 -0800</pubDate>
		<dc:creator>Steven C. Den Beste</dc:creator>
	</item><item>
		<title>By: null terminated</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054410</link>	
		<description>A) This is a very hard problem and new XSS attacks are being discovered every day, even on websites that have moderately &quot;good&quot; XSS protection. &lt;br&gt;
&lt;br&gt;
If you really need to do this, I&apos;d suggest copying code from someone who has already dealt from this problem. &lt;a href=&quot;http://www.ciforge.com/CodeIgniter_ApiDocs_1.4.1/__filesource/fsource_CodeIgniter_Libraries_librariesInput.php.html#a353&quot;&gt;Here&apos;s an xss_clean function&lt;/a&gt; from the Open Source project &lt;a href=&quot;http://codeigniter.com/&quot;&gt;Code Igniter&lt;/a&gt;. &lt;br&gt;
&lt;br&gt;
B) Allowing IMG tags could cause problems, specifically if your site does not properly protect against &lt;a href=&quot;http://en.wikipedia.org/wiki/Cross-site_request_forgery&quot;&gt;CSRF attacks&lt;/a&gt;. &lt;br&gt;
&lt;br&gt;
If someone can inject javascript into their site, they can violate the &lt;a href=&quot;http://en.wikipedia.org/wiki/Same_origin_policy&quot;&gt;same origin policy&lt;/a&gt; and perform a number of possibly unwanted actions to your site (basically reading the data off any page of your site).</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054410</guid>
		<pubDate>Mon, 03 Sep 2007 09:50:10 -0800</pubDate>
		<dc:creator>null terminated</dc:creator>
	</item><item>
		<title>By: geminus</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054412</link>	
		<description>I assume PHP.&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.htmlpurifier.org&quot;&gt;HTMLPurifier&lt;/a&gt;. The library looks complex on the surface (lots of options!) but it isn&apos;t - and it is very very configurable. I love it.&lt;br&gt;
&lt;br&gt;
You could also take a look at &lt;a href=&quot;http://sourceforge.net/projects/kses&quot;&gt;kses&lt;/a&gt; and &lt;a href=&quot;http://www.pixel-apes.com/safehtml/&quot;&gt;SafeHTML&lt;/a&gt;. &lt;br&gt;
&lt;br&gt;
I&apos;ve used all three. Purifier is the most flexible and powerful IME.&lt;br&gt;
&lt;br&gt;
There are always problems with hand-sanitizing JavaScript, it&apos;s not a simple matter of removing onclick handlers. Don&apos;t write your own from scratch if you can help. For example, there are other handlers which can be abused (&lt;a href=&quot;http://seclists.org/bugtraq/2007/May/0011.html&quot;&gt;one example with WordPress&lt;/a&gt;).&lt;br&gt;
&lt;br&gt;
In short, allow unsanitized JavaScript through on your page and it is pretty much game over... A simple remote .js embed allows an attacker to steal your clipboard contents, track any clicks/keystrokes you make on a page and lots of other nasties. Remember, statstrackers like Urchin/Analytics, Statcounter etc do all their monitoring with a single .js embed.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054412</guid>
		<pubDate>Mon, 03 Sep 2007 09:53:41 -0800</pubDate>
		<dc:creator>geminus</dc:creator>
	</item><item>
		<title>By: malevolent</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054428</link>	
		<description>The main thing to consider is that you need some code that&apos;ll parse the tags, only retain whitelisted tags/attributes, then rebuild the markup. Scripts that filter stuff out are generally easy to circumvent, you have to think in terms of what&apos;s allowed not what&apos;s forbidden and err on the side of caution. HTML Purifier is probably a good option.&lt;br&gt;
&lt;br&gt;
As well as JavaScript, you&apos;ll need to ban CSS, images and object/embed to be completely safe, and restrict links to http(s). If you need to allow images, you could provide an image upload facility (with rigorous limitations and validation) and only allow uploaded images to be referenced in the HTML.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054428</guid>
		<pubDate>Mon, 03 Sep 2007 10:16:05 -0800</pubDate>
		<dc:creator>malevolent</dc:creator>
	</item><item>
		<title>By: cmiller</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054432</link>	
		<description>It&apos;s safest to create your own language, and interpret that.  For everything that&apos;s not in your language, encode it.  &lt;br&gt;
E.g.,&lt;br&gt;
&lt;br&gt;
&quot;**Foo&amp;lt;SkriptHaxor!&amp;gt;**&quot;&lt;br&gt;
&lt;br&gt;
-&amp;gt;&lt;br&gt;
&lt;br&gt;
&quot;&amp;lt;strong&amp;gt;Foo&lt;strong&gt;&amp;amp;lt;&lt;/strong&gt;SkriptHaxor!&lt;strong&gt;&amp;amp;gt;&lt;/strong&gt;&amp;lt;/strong&amp;gt;&quot;&lt;br&gt;
&lt;br&gt;
Make it impossible to pass special characters through to an HTML intepreter.  For anything else, you will regret it.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054432</guid>
		<pubDate>Mon, 03 Sep 2007 10:21:14 -0800</pubDate>
		<dc:creator>cmiller</dc:creator>
	</item><item>
		<title>By: cschneid</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054437</link>	
		<description>this is a great page to see how large of a problem this really is: &lt;a href=&quot;http://ha.ckers.org/xss.html&quot;&gt;http://ha.ckers.org/xss.htm&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
You need to be able to defend against most of these, some of which are really really hard to detect.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054437</guid>
		<pubDate>Mon, 03 Sep 2007 10:26:10 -0800</pubDate>
		<dc:creator>cschneid</dc:creator>
	</item><item>
		<title>By: GregX3</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054445</link>	
		<description>This sounds trickier than I thought. &lt;br&gt;
&lt;br&gt;
Maybe it would help to show you exactly what I&apos;m trying to do.  This is a website that lets users create their own web generators/utilities.  And in the case where the utility generates HTML I want to allow the user to preview the HTML in a browser.  Here&apos;s an example of how it works now:&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.utilitymill.com/utility/Text_Diff&quot;&gt;http://www.utilitymill.com/utility/Text_Diff&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
There&apos;s some javascript to detect if there is HTML in the text area and provides a link to open that HTML in a new window.  I&apos;m thinking perhaps the same javascript could also detect anything dangerous and simply not render that link.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054445</guid>
		<pubDate>Mon, 03 Sep 2007 10:36:38 -0800</pubDate>
		<dc:creator>GregX3</dc:creator>
	</item><item>
		<title>By: yohko</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054462</link>	
		<description>&lt;em&gt;If you really want to be safe, you permit bold, italics, underlines and line breaks and nothing else whatever.&lt;/em&gt;&lt;br&gt;
&lt;br&gt;
&lt;small&gt;Really, nothing else?&lt;/small&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054462</guid>
		<pubDate>Mon, 03 Sep 2007 11:02:52 -0800</pubDate>
		<dc:creator>yohko</dc:creator>
	</item><item>
		<title>By: null terminated</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054468</link>	
		<description>Everything related to XSS only applies to data being stored on your server that will be displayed to other users. If users are only going to be seeing the HTML/javascript themselves and the user generated HTML is not stored on your server, you have nothing to worry about.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054468</guid>
		<pubDate>Mon, 03 Sep 2007 11:16:01 -0800</pubDate>
		<dc:creator>null terminated</dc:creator>
	</item><item>
		<title>By: null terminated</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054470</link>	
		<description>&lt;em&gt;If you really want to be safe, you permit bold, italics, underlines and line breaks and nothing else whatever.&lt;/em&gt;&lt;br&gt;
&lt;br&gt;
I&apos;d also like to see a justification for this statement.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054470</guid>
		<pubDate>Mon, 03 Sep 2007 11:23:10 -0800</pubDate>
		<dc:creator>null terminated</dc:creator>
	</item><item>
		<title>By: cmiller</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054498</link>	
		<description>null terminated, I think he means that you must adopt a closed-with-exceptions approach, rather than  open-with-exceptions.  We can&apos;t predict what the next exploit will be.  Heck, we can barely cleanse out what we know of already; once we put Turing machines into our browsers, we were screwed.&lt;br&gt;
&lt;br&gt;
So, if you&apos;re saying &apos;&quot;dl&quot; and &quot;ul&quot; and &quot;ol&quot; ... also&apos;, then yeah, fine. As long as they&apos;re simple and not likely to &lt;em&gt;embraced and extended&lt;/em&gt; in Internet Explorer v14.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054498</guid>
		<pubDate>Mon, 03 Sep 2007 11:51:00 -0800</pubDate>
		<dc:creator>cmiller</dc:creator>
	</item><item>
		<title>By: Artw</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054502</link>	
		<description>You want to watch those attributes as well - people can hide some funky stuff in there. From stuff like onload or onfail (combined with a fualty src) to stuff like Javascript running off of src or style attributes.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054502</guid>
		<pubDate>Mon, 03 Sep 2007 11:53:39 -0800</pubDate>
		<dc:creator>Artw</dc:creator>
	</item><item>
		<title>By: phrontist</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054513</link>	
		<description>In perl there is &lt;a href=&quot;http://search.cpan.org/~podmaster/HTML-Scrubber-0.08/Scrubber.pm&quot;&gt;HTML::Scrubber&lt;/a&gt;. I use it on &lt;a href=&quot;http://wrfl881.org&quot;&gt;this site&lt;/a&gt; to allow users to modify pages - but limit them to the following tags:&lt;br&gt;
&lt;br&gt;
a p b i u br h1 h2&lt;br&gt;
&lt;br&gt;
You absolutely shouldn&apos;t have a &quot;banned&quot; list. You &lt;strong&gt;must&lt;/strong&gt; have a whitelist and remove everything else. Also, make sure whatever you use filters attributes. Here is the function I pass everything through before presentation:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;br&gt;
sub cleanse { # Cleanse - Use an HTML::Scrubber object to remove nefarious markup&lt;br&gt;
	my $input = shift;&lt;br&gt;
	my $scrubber = HTML::Scrubber-&amp;gt;new( allow =&amp;gt; [ qw[ a p b i u br h1 h2 ] ] );&lt;br&gt;
	$scrubber-&amp;gt;rules(&lt;br&gt;
        a =&amp;gt; {&lt;br&gt;
            href =&amp;gt; 1, # only relative image links allowed&lt;br&gt;
            alt =&amp;gt; 1,                 # alt attribute allowed&lt;br&gt;
            &apos;*&apos; =&amp;gt; 0,                 # deny all other attributes&lt;br&gt;
	} );&lt;br&gt;
	return $scrubber-&amp;gt;scrub($input);&lt;br&gt;
}&lt;br&gt;
&lt;/pre&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054513</guid>
		<pubDate>Mon, 03 Sep 2007 12:01:33 -0800</pubDate>
		<dc:creator>phrontist</dc:creator>
	</item><item>
		<title>By: delmoi</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054515</link>	
		<description>GregX3: Are users going to see eachother&apos;s pages? If not then you don&apos;t really have anything to worry about.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054515</guid>
		<pubDate>Mon, 03 Sep 2007 12:02:41 -0800</pubDate>
		<dc:creator>delmoi</dc:creator>
	</item><item>
		<title>By: GregX3</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054516</link>	
		<description>so my website feature is safe then?  I&apos;m not sure I understand why.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054516</guid>
		<pubDate>Mon, 03 Sep 2007 12:03:07 -0800</pubDate>
		<dc:creator>GregX3</dc:creator>
	</item><item>
		<title>By: GregX3</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054521</link>	
		<description>delmoi, well any user can write a utility.  A utility could output arbitrary HTML.  Any other user could run the utility.  So yes, I suppose users do see each others pages.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054521</guid>
		<pubDate>Mon, 03 Sep 2007 12:04:50 -0800</pubDate>
		<dc:creator>GregX3</dc:creator>
	</item><item>
		<title>By: null terminated</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054525</link>	
		<description>cmiller: &lt;em&gt;Nothing else whatsoever&lt;/em&gt; makes me wonder if I&apos;m unaware of some attribute of these tags that don&apos;t exist in other tags. Is bold somehow more safe than strikeout? I don&apos;t understand why.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054525</guid>
		<pubDate>Mon, 03 Sep 2007 12:07:29 -0800</pubDate>
		<dc:creator>null terminated</dc:creator>
	</item><item>
		<title>By: null terminated</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054530</link>	
		<description>GregX3: There&apos;s two types of HTML/Javascript on your site. There&apos;s the HTML you generate for all your users, and there&apos;s the HTML that&apos;s generated in javascript.&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;1) The HTML/Javascript you generate&lt;/strong&gt;&lt;br&gt;
This needs to be protected from XSS attacks. If someone were able to inject code, it could be displayed to other users and possibly do nasty things.&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;2) The HTML generated on the client side&lt;/strong&gt;&lt;br&gt;
This code is only to one user. If that user is malicious and were to modify code, he is the only person who&apos;d see this code. This is equivalent to someone writing a virus and releasing it on his own machine. A virus is not a threat unless the virus writer unleashes on the world. In the same way, Javascript is not a threat unless it&apos;s somehow sent to other users. &lt;br&gt;
&lt;br&gt;
If you&apos;re familiar with Greasemonkey, this might be more clear. Greasemonkey allows users to inject code into any page they visit. This is equivalent to what you&apos;re doing. In both cases, the user (malicious or not) is the only one executing the javascript.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054530</guid>
		<pubDate>Mon, 03 Sep 2007 12:14:36 -0800</pubDate>
		<dc:creator>null terminated</dc:creator>
	</item><item>
		<title>By: null terminated</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054535</link>	
		<description>*This code is only &lt;em&gt;displayed&lt;/em&gt; to one user.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054535</guid>
		<pubDate>Mon, 03 Sep 2007 12:17:16 -0800</pubDate>
		<dc:creator>null terminated</dc:creator>
	</item><item>
		<title>By: GregX3</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054541</link>	
		<description>null terminated, I fall in category 1 then.  So I probably need some protection.&lt;br&gt;
&lt;br&gt;
It seems to me that all the XSS exploits involve loading another page/resource.  So perhaps I could just detect all the top level domains e.g., .org, .com, .ca, etc and not offer to preview HTML in a browser if any of those are detected?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054541</guid>
		<pubDate>Mon, 03 Sep 2007 12:22:00 -0800</pubDate>
		<dc:creator>GregX3</dc:creator>
	</item><item>
		<title>By: bonaldi</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054542</link>	
		<description>I think it was hyperbole, but the intention is right. Although you can add style tags to even simple tags like b and i which, while they won&apos;t necessarily run javascript, can make a mess of yr page, or pull images that leave you open to XSS.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054542</guid>
		<pubDate>Mon, 03 Sep 2007 12:22:33 -0800</pubDate>
		<dc:creator>bonaldi</dc:creator>
	</item><item>
		<title>By: null terminated</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054554</link>	
		<description>GregX3: In order for you to be vulnerable, you need to be accepting HTML/Javascript from a user, storing this on your server and displaying it to other users. You don&apos;t seem to be doing this.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054554</guid>
		<pubDate>Mon, 03 Sep 2007 12:33:45 -0800</pubDate>
		<dc:creator>null terminated</dc:creator>
	</item><item>
		<title>By: null terminated</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054558</link>	
		<description>bonaldi: b and i &lt;em&gt;can&lt;/em&gt; include javascript, which makes the statement wrong in two directions (permitting the tags &lt;em&gt;is&lt;/em&gt; unsafe and disallowing other tags &lt;em&gt;does not&lt;/em&gt; add any protection)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054558</guid>
		<pubDate>Mon, 03 Sep 2007 12:36:43 -0800</pubDate>
		<dc:creator>null terminated</dc:creator>
	</item><item>
		<title>By: GregX3</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054561</link>	
		<description>null terminated, any user can make or edit the code for a utility.  For example, for the text diff example I linked to, a user could come in and make the output of the utility be arbitrary HTML.  (click the edit link on that page to see what I mean)&lt;br&gt;
&lt;br&gt;
Think of my website like a wiki for utilities.  Does that make sense?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054561</guid>
		<pubDate>Mon, 03 Sep 2007 12:37:47 -0800</pubDate>
		<dc:creator>GregX3</dc:creator>
	</item><item>
		<title>By: null terminated</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054566</link>	
		<description>Ah, yes. I incorrectly assumed you were talking about the HTML in the &quot;output&quot; textarea. You do need to properly sanitize output. &lt;br&gt;
&lt;br&gt;
This looks like a very cool website. Make sure you&apos;re properly sandboxing the python environment.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054566</guid>
		<pubDate>Mon, 03 Sep 2007 12:44:58 -0800</pubDate>
		<dc:creator>null terminated</dc:creator>
	</item><item>
		<title>By: bonaldi</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054579</link>	
		<description>It sounds risky to me. It might be best to display the output of the generator as the raw HTML (ie, encode all the greater and less thans), and let them copy and paste into their favourite editor. Would that kill the usefulness of your utils?&lt;br&gt;
&lt;br&gt;
null terminated: yes, that&apos;s right of course. No more benefit of the doubt for scdb.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054579</guid>
		<pubDate>Mon, 03 Sep 2007 12:54:39 -0800</pubDate>
		<dc:creator>bonaldi</dc:creator>
	</item><item>
		<title>By: GregX3</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054587</link>	
		<description>bonaldi, I think it kills a lot of the usefulness to not show the HTML generated in a browser though.&lt;br&gt;
&lt;br&gt;
I liked the first PHP cleaner approach mentioned near the top of this thread but I&apos;d prefer the function to be in javascript.  Anyone know of anything like that?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054587</guid>
		<pubDate>Mon, 03 Sep 2007 13:05:18 -0800</pubDate>
		<dc:creator>GregX3</dc:creator>
	</item><item>
		<title>By: cmiller</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054661</link>	
		<description>GregX3, you said,&lt;br&gt;
&lt;br&gt;
&lt;em&gt;It seems to me that all the XSS exploits involve loading another page/resource. So perhaps I could just detect all the top level domains e.g., .org, .com, .ca, etc and not offer to preview HTML in a browser if any of those are detected?&lt;/em&gt;&lt;br&gt;
&lt;br&gt;
I shan&apos;t harp on this any more.  An &quot;open-with-exceptions&quot; scheme like one you&apos;re planning is doomed.  You can never anticipate and plan for all the &lt;a href=&quot;http://en.wikipedia.org/wiki/Data:_URI_scheme&quot;&gt;weird&lt;/a&gt; &lt;a href=&quot;http://en.wikipedia.org/wiki/DNS_cache_poisoning&quot;&gt;things&lt;/a&gt; that might exist in the universe.  The only (nearly) safe scheme is to permit nothing, with a list of exceptions.  That exceptions list had better be planned out very well.&lt;br&gt;
&lt;br&gt;
Good luck.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054661</guid>
		<pubDate>Mon, 03 Sep 2007 14:39:44 -0800</pubDate>
		<dc:creator>cmiller</dc:creator>
	</item><item>
		<title>By: null terminated</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054712</link>	
		<description>I _believe_ you could host the untrusted data on a subdomain (like unsafe.utilitymill.com) without filtering anything.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054712</guid>
		<pubDate>Mon, 03 Sep 2007 15:53:02 -0800</pubDate>
		<dc:creator>null terminated</dc:creator>
	</item><item>
		<title>By: bonaldi</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054817</link>	
		<description>There were some subdomain cookie exploits in IE years back, however, and nothing to say there might not be again ...</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054817</guid>
		<pubDate>Mon, 03 Sep 2007 18:09:46 -0800</pubDate>
		<dc:creator>bonaldi</dc:creator>
	</item><item>
		<title>By: smackfu</title>
		<link>http://ask.metafilter.com/70682/How-to-Sanitize-HTML-Javascript-Security#1054958</link>	
		<description>This is why vBulletin uses its own non-html language.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.70682-1054958</guid>
		<pubDate>Mon, 03 Sep 2007 20:29:12 -0800</pubDate>
		<dc:creator>smackfu</dc:creator>
	</item>
	</channel>
</rss>
