<p>This link describes an exploit into my app using fckEditor:
<a href="http://knitinr.blogspot.com/2008/07/script-exploit-via-fckeditor.html" rel="nofollow noreferrer">http://knitinr.blogspot.com/2008/07/script-exploit-via-fckeditor.html</a></p>

<p>How do I make my app secure while still using fckEditor?   Is it an fckEditor configuration?   Is it some processing I'm supposed to do server-side after I grab the text from fckEditor?</p>

<p>It's a puzzle because fckEditor <em>USES</em> html tags for its formatting, so I can't just HTML encode when I display back the text.</p>

[{'answer_id': 65802, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 2, 'selected': False, 'text': '<p>The bug is not actually FCKeditors fault. As long as you let users edit HTML that will be displayed on your web site they will always have to possibility to do harm unless you check the data before you output it.</p>\n\n<p>Some people use HTMLencoding to do this, but that will destroy all the formatting done by FCKeditor, not what you want.</p>\n\n<hr>\n\n<p>Maybe you can use the <a href="http://msdn.microsoft.com/en-us/library/aa973813.aspx" rel="nofollow noreferrer">Microsoft Anti-Cross Site Scripting Library</a>. Samples on <a href="http://msdn.microsoft.com/en-us/library/aa973813.aspx" rel="nofollow noreferrer">MSDN</a></p>\n'}, {'answer_id': 65808, 'author': 'Paweł Hajdan', 'author_id': 9403, 'author_profile': 'https://Stackoverflow.com/users/9403', 'pm_score': 4, 'selected': True, 'text': '<p>Sanitize html server-side, no other choice. For PHP it would be <a href="http://htmlpurifier.org" rel="nofollow noreferrer">HTML Purifier</a>, for .NET I don\'t know. It\'s tricky to sanitize HTML - it\'s not sufficient to strip script tags, you also have to watch out for on* event handlers and even more, thanks to stupidities of IE for example.</p>\n\n<p>Also with custom html and css it\'s easy to hijack look and layout of your site - using overlay (absolutely positioned) which covers all screen etc. Be prepared for that.</p>\n'}, {'answer_id': 65851, 'author': 'John Millikin', 'author_id': 3560, 'author_profile': 'https://Stackoverflow.com/users/3560', 'pm_score': 2, 'selected': False, 'text': "<blockquote>\n  <p>Is it some processing I'm supposed to do server-side after I grab the text from fckEditor?</p>\n</blockquote>\n\n<p>Precisely. StackOverflow had some early issues related to this as well. The easiest way to solve it is to use an HTML library to parse user's input, and then escape any tags you don't want in the output. Do this as a post-processing step when printing to the page -- the data in the database should be the exact same as what the user typed in.</p>\n\n<p>For example, if the user enters <code>&lt;b&gt;&lt;script&gt;evil here&lt;/script&gt;&lt;/b&gt;</code>, your code would translate it to <code>&lt;b&gt;&amp;lt;script&amp;gt;evil here&amp;lt;/script&amp;gt;&lt;/b&gt;</code> before rendering the page.</p>\n\n<p>And <strong>do not</strong> use regular expressions for solving this, that's just an invitation for somebody clever to break it again.</p>\n"}, {'answer_id': 65919, 'author': 'John Millikin', 'author_id': 3560, 'author_profile': 'https://Stackoverflow.com/users/3560', 'pm_score': 0, 'selected': False, 'text': "<blockquote>\n  <p>I understand the DONTS. I'm lacking a DO.</p>\n</blockquote>\n\n<p>Is use of FCKEditor a requirement, or can you use a different editor/markup language? I advise using Markdown and WMD Editor, the same language used by StackOverflow. The Markdown library for .NET should have an option to escape all HTML tags -- be sure to turn it on.</p>\n"}, {'answer_id': 486205, 'author': 'Jon Adams', 'author_id': 2291, 'author_profile': 'https://Stackoverflow.com/users/2291', 'pm_score': 0, 'selected': False, 'text': '<p>XSS is a tricky thing. I suggest some reading:</p>\n<ul>\n<li><a href="http://www.codinghorror.com/blog/archives/001116.html" rel="nofollow noreferrer">Is HTML a Humane Markup Language?</a></li>\n<li><a href="https://blog.stackoverflow.com/2008/06/safe-html-and-xss/">Safe HTML and XSS</a></li>\n</ul>\n<p>Anyway, my summary is when it comes down to it, you have to only allow in strictly accepted items; you can\'t  reject known exploit vectors because or you\'ll always be behind the eternal struggle.</p>\n'}, {'answer_id': 927278, 'author': 'Chris', 'author_id': 114454, 'author_profile': 'https://Stackoverflow.com/users/114454', 'pm_score': 2, 'selected': False, 'text': '<p>FCKEditor can be configured to use only a few tags.  You will need to encode everything except for those few tags.</p>\n\n<p>Those tags are: &lt;strong> &lt;em> &lt;u> &lt;ol> &lt;ul> &lt;li> &lt;p> &lt;blockquote> &lt;font> &lt;span>.</p>\n\n<p>The font tag only should have face and size attributes.\nThe span tag should only have a class attribute.</p>\n\n<p>No other attributes should be allowed for these tags.</p>\n'}, {'answer_id': 2121316, 'author': 'Merovex', 'author_id': 257195, 'author_profile': 'https://Stackoverflow.com/users/257195', 'pm_score': 0, 'selected': False, 'text': '<p>I think the issue raised by some is not that Fckeditor only encodes a few tags. This is a naive assumption that an evil user will use the Fckeditor to write his malice. The tools that allow manual changing of input are legion.</p>\n\n<p>I treat all user data as tainted; and use Markdown to convert text to HTML. It sanitizes any HTML found in the text, which reduces malice.</p>\n'}]
['https://Stackoverflow.com/questions/65734', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9328/']