summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Release Tools Bot <robert+release-tools@gitlab.com>2019-06-26 21:40:35 +0000
committerGitLab Release Tools Bot <robert+release-tools@gitlab.com>2019-06-26 21:40:35 +0000
commit74da71f88d239478cc9e68433c5d2b79e1cadb3e (patch)
tree60e2c6151f1f8aab18b5a68f17bf09e476c858ff
parente34d621920f0bb7cbabfbc01758eea5c0d8ef6ef (diff)
parent327f179a1ec5e64096f73b83b6a7c78c1a937e2d (diff)
downloadgitlab-ce-74da71f88d239478cc9e68433c5d2b79e1cadb3e.tar.gz
Merge branch 'security-DOS_issue_comments_banzai-11-11' into '11-11-stable'
Fix DOS when rendering issue/MR comments See merge request gitlab/gitlabhq!3158
-rw-r--r--changelogs/unreleased/security-DOS_issue_comments_banzai.yml5
-rw-r--r--lib/banzai/filter/relative_link_filter.rb2
-rw-r--r--spec/lib/banzai/filter/relative_link_filter_spec.rb5
3 files changed, 11 insertions, 1 deletions
diff --git a/changelogs/unreleased/security-DOS_issue_comments_banzai.yml b/changelogs/unreleased/security-DOS_issue_comments_banzai.yml
new file mode 100644
index 00000000000..2405b1a4f5f
--- /dev/null
+++ b/changelogs/unreleased/security-DOS_issue_comments_banzai.yml
@@ -0,0 +1,5 @@
+---
+title: Fix Denial of Service for comments when rendering issues/MR comments
+merge_request:
+author:
+type: security
diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb
index 199b3533cf4..cdf97e75491 100644
--- a/lib/banzai/filter/relative_link_filter.rb
+++ b/lib/banzai/filter/relative_link_filter.rb
@@ -100,7 +100,7 @@ module Banzai
end
def relative_file_path(uri)
- path = Addressable::URI.unescape(uri.path)
+ path = Addressable::URI.unescape(uri.path).delete("\0")
request_path = Addressable::URI.unescape(context[:requested_path])
nested_path = build_relative_path(path, request_path)
file_exists?(nested_path) ? nested_path : path
diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb
index dad0a5535c0..a6e8a2fc8fc 100644
--- a/spec/lib/banzai/filter/relative_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb
@@ -83,6 +83,11 @@ describe Banzai::Filter::RelativeLinkFilter do
expect { filter(act) }.not_to raise_error
end
+ it 'does not explode with an escaped null byte' do
+ act = link("/%00")
+ expect { filter(act) }.not_to raise_error
+ end
+
it 'does not raise an exception with a space in the path' do
act = link("/uploads/d18213acd3732630991986120e167e3d/Landscape_8.jpg \nBut here's some more unexpected text :smile:)")
expect { filter(act) }.not_to raise_error