Skip to content

Commit

Permalink
fix: Fixed a mXSS bypass reported in #482
Browse files Browse the repository at this point in the history
  • Loading branch information
cure53 committed Nov 2, 2020
1 parent e95b0de commit ee33fae
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dist/purify.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.cjs.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.es.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ function createDOMPurify(window = getGlobal()) {
/* Take care of an mXSS pattern using p, br inside svg, math */
if (
(tagName === 'svg' || tagName === 'math') &&
currentNode.querySelectorAll('p, br').length !== 0
currentNode.querySelectorAll('p, br, form').length !== 0
) {
_forceRemove(currentNode);
return true;
Expand Down
13 changes: 10 additions & 3 deletions test/fixtures/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,26 +1116,33 @@ module.exports = [
"<svg></svg><b><style><b title='</style><img>'&gt;</b>"
]
}, {
"title": "Tests against nesting-based mXSS behavior 1/3",
"title": "Tests against nesting-based mXSS behavior 1/4",
"payload": "<form><math><mtext></form><form><mglyph><style><img src=x onerror=alert(1)>",
"expected": [
"<form></form>",
"<form><math><mtext><form><mglyph></mglyph></form></mtext></math></form>"
]
}, {
"title": "Tests against nesting-based mXSS behavior 2/3",
"title": "Tests against nesting-based mXSS behavior 2/4",
"payload": "<math><mtext><table><mglyph><style><math href=javascript:alert(1)>CLICKME</math>",
"expected": [
"",
"<math><mtext><mglyph></mglyph><table></table></mtext></math>"
]
}, {
"title": "Tests against nesting-based mXSS behavior 3/3",
"title": "Tests against nesting-based mXSS behavior 3/4",
"payload": "<math><mtext><table><mglyph><style><!--</style><img title=\"--&gt;&lt;img src=1 onerror=alert(1)&gt;\">",
"expected": [
"",
"<math><mtext><mglyph><img title=\"--><img src=1 onerror=alert(1)>\"></mglyph><table></table></mtext></math>"
]
}, {
"title": "Tests against nesting-based mXSS behavior 4/4",
"payload": "<form><math><mtext></form><form><mglyph><svg><mtext><style><path id=\"</style><img onerror=alert(1) src>\">",
"expected": [
"",
"<form></form>"
]
}, {
"title": "Tests against proper handling of leading whitespaces",
"payload": " ",
Expand Down

0 comments on commit ee33fae

Please sign in to comment.