As of UC version 20.2, this plug-in can also sanitize its output to avoid Cross Site Scripting attacks (XSS).
Simply enable the plug-in's "Sanitize Content" option, and all dangerous content will be stripped away, leaving the legal HTML intact. This way you can allow users to edit HTML code, say via a Rich Text Editor, and present that HTML to other users, without risking an XSS attack. We recommend using this plug-in whenever you wish to present HTML you didn't write yourself.
Take the following example. Both of the following 2 instances of the UC - PL/SQL Dynamic Content plug-in are based on the same dangerous HTML source:
<!-- attack 1 nonexistent image-->
<img src="nonexistent" onerror="console.log('XSS 1');">
<!-- attack 2 regular script tag-->
<script>console.log('XSS 2');</script>
<!-- attack 3 mouseover-->
<h3 onmouseover="console.log('XSS 3');">Hello UC World!</h3>
Hello UC World!
Now check your console. You should see XSS 1 and 2 being console logged, but only once, caused by the left example. The right example was sanitized and did not cause any damage.
Same with the mouseover event. As you hover over the left "Hello UC World" you will see a message being logged. When hovering over the same text on the right, nothing will happen.
This demonstration uses a simple console.log, but an attacker could easily use the same technique to steal your cookie and session and hijack your session or steal sensitive information. As a rule of thumb, untrusted HTML should always be either completely escaped, or sanitized.
Under the hood, this plug-in uses the popular JavaScript library DOMPurify. If you wish to fine control its options you can use the JavaScript Initialization Code as follows:
function(options){
// allow only h1, h2 and h3 elements, very strict
options.DOMPurifyConfig = {
ALLOWED_TAGS: ['h1', 'h2', 'h3']
};
}
See the DOMPurify documentation for more info.