CVE-2020-9444: Prevent reverse tabnabbing attacks.

While we could fix this issue by changing the markdown processor,
doing so is not a robust solution, because even a momentary bug in the
markdown processor could allow cached messages that do not follow our
security policy.

This change ensures that even if our markdown processor has bugs that
result in rendered content that does not properly follow our policy of
using rel="noopener noreferrer" on links, we'll still do something
reasonable.

Co-authored-by: Tim Abbott <tabbott@zulipchat.com>
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-02-28 14:59:07 -08:00
committed by Tim Abbott
parent e3a4aeeffa
commit 68cfcd6446
20 changed files with 95 additions and 17 deletions

View File

@@ -773,7 +773,7 @@ exports.render_and_show_preview = function (preview_spinner, preview_content_box
rendered_preview_html = rendered_content;
}
preview_content_box.html(rendered_preview_html);
preview_content_box.html(util.clean_user_content_links(rendered_preview_html));
if (page_params.emojiset === "text") {
preview_content_box.find(".emoji").replaceWith(function () {
const text = $(this).attr("title");