Skip to content
Snippets Groups Projects
Commit d0dadd3b authored by Steve Xuereb's avatar Steve Xuereb :speech_balloon:
Browse files

Merge branch 'security-mermaid-xss-11-3' into 'security-11-3'

[11.3] Fix XSS in mermaid diagrams

See merge request gitlab/gitlabhq!2640
parents 7e1abc38 0d64da48
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -25,6 +25,9 @@ export default function renderMermaid($els) {
},
// mermaidAPI options
theme: 'neutral',
flowchart: {
htmlLabels: false,
},
});
 
$els.each((i, el) => {
Loading
Loading
---
title: Configure mermaid to not render HTML content in diagrams
merge_request:
author:
type: security
Loading
Loading
@@ -40,6 +40,18 @@ describe "User comments on issue", :js do
 
expect(page.find('pre code').text).to eq code_block_content
end
it "does not render html content in mermaid" do
html_content = "<img onerror=location=`javascript\\u003aalert\\u0028document.domain\\u0029` src=x>"
mermaid_content = "graph LR\n B-->D(#{html_content});"
comment = "```mermaid\n#{mermaid_content}\n```"
add_note(comment)
wait_for_requests
expect(page.find('svg.mermaid')).to have_content html_content
end
end
 
context "when editing comments" do
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ describe 'Mermaid rendering', :js do
visit project_issue_path(project, issue)
 
%w[A B C D].each do |label|
expect(page).to have_selector('svg foreignObject', text: label)
expect(page).to have_selector('svg text', text: label)
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment