summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMason Freed <masonfreed@chromium.org>2019-11-30 07:48:15 +0000
committerMichael BrĂ¼ning <michael.bruning@qt.io>2020-03-24 08:12:58 +0000
commit4b2fb2f933fb85572334a90f31dabafb1883493b (patch)
tree0a4f6d54ac6ce3c91412ded04489be5445427a5b
parentdec516df71164e85808353a44f748d7a31cbf027 (diff)
downloadqtwebengine-chromium-4b2fb2f933fb85572334a90f31dabafb1883493b.tar.gz
[Backport] CVE-2020-6413 - Inappropriate implementation in Blink
Manual backport of patch originally reviewed on https://chromium-review.googlesource.com/c/chromium/src/+/1940722: Fix parser mXSS sanitizer bypass for <p> and <br> within foreign context Prior to this CL, the following code: <svg></p></svg> parsed to this innerHTML: <svg><p></p></svg> This is in contrast to this code: <svg><p></svg> which parses to <svg></svg><p></p> The fact that the </p> is left inside the <svg> allowed sanitizer bypasses as detailed in [1]. Please also see [2] for the spec discussion. With this CL, </p> and </br> within a foreign context now cause the closing of the foreign context. [1] https://research.securitum.com/dompurify-bypass-using-mxss/ [2] https://github.com/whatwg/html/issues/5113 Bug: 1005713 Change-Id: Iecaced38ed06c74296731c0bdcc10d2bbb462ff8 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_tree_builder_simulator.cc8
2 files changed, 14 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.cc b/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.cc
index bbfd0b70b7d..5452a02fab3 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.cc
@@ -2691,6 +2691,12 @@ void HTMLTreeBuilder::ProcessTokenInForeignContent(AtomicHTMLToken* token) {
tree_.OpenElements()->Pop();
return;
}
+ if (token->GetName() == brTag || token->GetName() == pTag) {
+ ParseError(token);
+ tree_.OpenElements()->PopUntilForeignContentScopeMarker();
+ ProcessEndTag(token);
+ return;
+ }
if (!tree_.CurrentStackItem()->IsInHTMLNamespace()) {
// FIXME: This code just wants an Element* iterator, instead of an
// ElementRecord*
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder_simulator.cc b/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder_simulator.cc
index ace64a51342..3a191f83c56 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder_simulator.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder_simulator.cc
@@ -188,6 +188,14 @@ HTMLTreeBuilderSimulator::SimulatedToken HTMLTreeBuilderSimulator::Simulate(
}
}
+ if (token.GetType() == HTMLToken::kEndTag && InForeignContent()) {
+ const String& tag_name = token.Data();
+ if (ThreadSafeMatch(tag_name, pTag) ||
+ ThreadSafeMatch(tag_name, brTag)) {
+ namespace_stack_.pop_back();
+ }
+ }
+
if (token.GetType() == HTMLToken::kEndTag ||
(token.GetType() == HTMLToken::kStartTag && token.SelfClosing() &&
InForeignContent())) {