News for hackers. Stuff that matters.
Re:HTML5 Security Cheatsheet: What your browser does when yo... by benmanns on Friday November 16, 2012 @12:06PM (#4794670)
Sometimes you have to allow some user input, like <b>, <font>, or <i> tags in those WYSIWYG editors. This is a reference for what you should remove from your whitelist or add to your blacklist.
Re:HTML5 Security Cheatsheet: What your browser does when yo... by tptacek on Friday November 16, 2012 @01:59PM (#4795302)
The right way to handle this problem is to scrape the content out of the incoming HTML, do a best-effort pass at remembering the formatting rules expressed in it, entity-encode everything, and regenerate the HTML markup from scratch.

It is never a good idea to accept HTML from a client, attempt to clean it up, and then pass it directly into the DOM of a server-generated page.

Re:HTML5 Security Cheatsheet: What your browser does when yo... by vog on Friday November 16, 2012 @12:21PM (#4794745)
I can't believe anyone has attributes like "onfocus" on their whitelist.

Although I respect the site's aim for completeness, the whole site could be shortened to one example of each issue. One example of "on..." attributes, one example of "javascript:" URLs, and so on. I don't see the value of the second, third, yet-another "on..." example. This is just hiding the deeper issues in a mess of seemingly clever examples.

Regarding the blacklist proposal, I really hope that nobody is seriously using those for HTML! One typo, one forgotten entry, or one new browser feature, and the blacklist's security drops to zero.

Re:HTML5 Security Cheatsheet: What your browser does when yo... by Adirael on Friday November 16, 2012 @12:17PM (#4794721)
Still, OP's right. If you need to let them use plain HTML (it's better to use markdown or something similar) just parse it and remove any attributes and tags not on your whitelist.
Re:HTML5 Security Cheatsheet: What your browser does when yo... by TeMPOraL on Friday November 16, 2012 @12:47PM (#4794891)
Or make them use Markdown, org-mode syntax, BBCode or s-expressions ({b text in bold {i and italics}}). User formatting should never go directly to the browser, without being reinterpreted by the website.