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

Merge branch...

Merge branch 'security-11-3-xss-in-markdown-following-unrecognized-html-element' into 'security-11-3'

[11.3] XSS in markdown following unrecognized HTML element

See merge request gitlab/gitlabhq!2633
parents d0dadd3b 918a7424
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -15,7 +15,7 @@ module CacheMarkdownField
# Increment this number every time the renderer changes its output
CACHE_REDCARPET_VERSION = 3
CACHE_COMMONMARK_VERSION_START = 10
CACHE_COMMONMARK_VERSION = 11
CACHE_COMMONMARK_VERSION = 12
 
# changes to these attributes cause the cache to be invalidates
INVALIDATED_BY = %w[author project].freeze
Loading
Loading
---
title: Fix possible XSS attack in Markdown urls with spaces
merge_request:
author:
type: security
Loading
Loading
@@ -17,6 +17,9 @@ module Banzai
# This is a small extension to the CommonMark spec. If they start allowing
# spaces in urls, we could then remove this filter.
#
# Note: Filter::SanitizationFilter should always be run sometime after this filter
# to prevent XSS attacks
#
class SpacedLinkFilter < HTML::Pipeline::Filter
include ActionView::Helpers::TagHelper
 
Loading
Loading
Loading
Loading
@@ -10,13 +10,16 @@ module Banzai
def self.filters
@filters ||= FilterArray[
Filter::PlantumlFilter,
# Must always be before the SanitizationFilter to prevent XSS attacks
Filter::SpacedLinkFilter,
Filter::SanitizationFilter,
Filter::SyntaxHighlightFilter,
 
Filter::MathFilter,
Filter::ColorFilter,
Filter::MermaidFilter,
Filter::SpacedLinkFilter,
Filter::VideoLinkFilter,
Filter::ImageLazyLoadFilter,
Filter::ImageLinkFilter,
Loading
Loading
Loading
Loading
@@ -104,5 +104,17 @@ describe Banzai::Pipeline::GfmPipeline do
 
expect(output).to include("src=\"test%20image.png\"")
end
it 'sanitizes the fixed link' do
markdown_xss = "[xss](javascript: alert%28document.domain%29)"
output = described_class.to_html(markdown_xss, project: project)
expect(output).not_to include("javascript")
markdown_xss = "<invalidtag>\n[xss](javascript:alert%28document.domain%29)"
output = described_class.to_html(markdown_xss, project: project)
expect(output).not_to include("javascript")
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