Skip to content

Commit e3e2df3

Browse files
authored
Merge pull request github#12166 from erik-krogh/more-html-san
JS: add `HtmlSanitizer` as a sanitizer DOMBasedXss
2 parents 028fcc7 + b85bfc8 commit e3e2df3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/DomBasedXssCustomizations.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ module DomBasedXss {
287287

288288
private class IsEscapedInSwitchSanitizer extends Sanitizer, Shared::IsEscapedInSwitchSanitizer { }
289289

290+
private class HtmlSanitizerAsSanitizer extends Sanitizer instanceof HtmlSanitizerCall { }
291+
290292
/**
291293
* Holds if there exists two dataflow edges to `succ`, where one edges is sanitized, and the other edge starts with `pred`.
292294
*/

javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom/xss-through-dom.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,11 @@ const cashDom = require("cash-dom");
139139
const src = document.getElementById("#link").src;
140140
cash("#id").html(src); // NOT OK.
141141
cashDom("#id").html(src); // NOT OK
142+
143+
var DOMPurify = {
144+
sanitize: function (src) {
145+
return src; // to model spuriously finding an edge. The below is still OK.
146+
}
147+
};
148+
cashDom("#id").html(DOMPurify ? DOMPurify.sanitize(src) : src); // OK
142149
})();

0 commit comments

Comments
 (0)