Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting XSS Filter for (X)HTML Based on White List
    text
    copied!<p>I need to implement a simple and efficient XSS Filter in C++ for <a href="http://cppcms.sourceforge.net" rel="nofollow noreferrer">CppCMS</a>. I can't use existing high quality filters written in PHP because because it is high performance framework that uses C++.</p> <p>The basic idea is provide a filter that have a while list of HTML tags and a white list of options for these tags. For example. typical HTML input can consist of <code>&lt;b&gt;</code>, <code>&lt;i&gt;</code>, tags and <code>&lt;a&gt;</code> tag with <code>href</code>. But straightforward implementation is not good enough, because, even allowed simple links may include XSS:</p> <pre><code>&lt;a href="javascript:alert('XSS')"&gt;Click On Me&lt;/a&gt; </code></pre> <p>There are many other examples can be found <a href="http://ha.ckers.org/xss.html" rel="nofollow noreferrer">there</a>. So I though also about a possibility to create a white list of prefixes for tags like href/src -- so I always need to check if it starts with <code>(https?|ftp)://</code></p> <p><strong>Questions:</strong></p> <ul> <li>Are these assumptions are good enough for most of purposes? Meaning that If I do not give an options for <code>style</code> tags and check src/href using white list of prefixes it solves XSS problems? Are there problems that can't be fixes this way?</li> <li>Is there a good reference for formal grammar of HTML/XHTML in order to write simple parser that would cleanup all incorrect of forbidden tags like <code>&lt;script&gt;</code></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload