Commit 0bb4813
committed
JavaScript: Add setHTMLUnsafe and parseHTMLUnsafe as XSS sinks
Add support for two new HTML Sanitizer API methods that interpret
arguments as HTML without sanitization:
- `Element.setHTMLUnsafe(html)`: Added to `interpretsArgumentsAsHtml`
in DOM.qll, following the same pattern as `insertAdjacentHTML` and
`document.write`. Receiver validation via `isDomNode` is inherited
from `DomMethodCallNode`.
- `Document.parseHTMLUnsafe(html)`: Added to `HtmlParserSink` in
DomBasedXssCustomizations.qll, following the same
`GlobalVarRefNode` pattern as `DOMParser.parseFromString`. This
is a static method on the `Document` class.
Both methods are part of the HTML Sanitizer API and are shipping in
browsers (Chrome 124+, Firefox 148+). Unlike their safe counterparts
(`setHTML`, `parseHTML`), these methods do not sanitize input and are
therefore XSS sinks.
References:
- https://developer.mozilla.org/en-US/docs/Web/API/Element/setHTMLUnsafe
- https://developer.mozilla.org/en-US/docs/Web/API/Document/parseHTMLUnsafe_static1 parent fb8b569 commit 0bb4813
File tree
2 files changed
+7
-0
lines changed- javascript/ql/lib/semmle/javascript/security/dataflow
2 files changed
+7
-0
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
199 | 204 | | |
200 | 205 | | |
201 | 206 | | |
| |||
0 commit comments