Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
11a72bc3
Commit
11a72bc3
authored
Mar 26, 2021
by
Mario Celi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Escape HTML on scoped labels tooltip
parent
2eaa98f2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
6 deletions
+22
-6
ee/changelogs/unreleased/security-291004-scoped-label-xss.yml
...hangelogs/unreleased/security-291004-scoped-label-xss.yml
+5
-0
ee/lib/ee/banzai/filter/label_reference_filter.rb
ee/lib/ee/banzai/filter/label_reference_filter.rb
+8
-2
ee/spec/lib/banzai/filter/label_reference_filter_spec.rb
ee/spec/lib/banzai/filter/label_reference_filter_spec.rb
+8
-3
lib/gitlab/markdown_cache.rb
lib/gitlab/markdown_cache.rb
+1
-1
No files found.
ee/changelogs/unreleased/security-291004-scoped-label-xss.yml
0 → 100644
View file @
11a72bc3
---
title
:
Escape HTML on scoped labels tooltip
merge_request
:
author
:
type
:
security
ee/lib/ee/banzai/filter/label_reference_filter.rb
View file @
11a72bc3
...
@@ -10,12 +10,18 @@ module EE
...
@@ -10,12 +10,18 @@ module EE
def
data_attributes_for
(
text
,
parent
,
object
,
link_content:
false
,
link_reference:
false
)
def
data_attributes_for
(
text
,
parent
,
object
,
link_content:
false
,
link_reference:
false
)
return
super
unless
object
.
scoped_label?
return
super
unless
object
.
scoped_label?
# Enabling HTML tooltips for scoped labels here but we do not need to do any additional
# Enabling HTML tooltips for scoped labels here and additional escaping is done in `object_link_title`
# escaping because the label's tooltips are already stripped of dangerous HTML
super
.
merge!
(
super
.
merge!
(
html:
true
html:
true
)
)
end
end
override
:object_link_title
def
object_link_title
(
object
,
matches
)
return
super
unless
object
.
scoped_label?
ERB
::
Util
.
html_escape
(
super
)
end
end
end
end
end
end
end
...
...
ee/spec/lib/banzai/filter/label_reference_filter_spec.rb
View file @
11a72bc3
...
@@ -7,7 +7,8 @@ RSpec.describe Banzai::Filter::LabelReferenceFilter do
...
@@ -7,7 +7,8 @@ RSpec.describe Banzai::Filter::LabelReferenceFilter do
let
(
:project
)
{
create
(
:project
,
:public
,
name:
'sample-project'
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
name:
'sample-project'
)
}
let
(
:label
)
{
create
(
:label
,
name:
'label'
,
project:
project
)
}
let
(
:label
)
{
create
(
:label
,
name:
'label'
,
project:
project
)
}
let
(
:scoped_label
)
{
create
(
:label
,
name:
'key::value'
,
project:
project
)
}
let
(
:scoped_description
)
{
'xss <script>alert("scriptAlert");</script> &<a>lt;svg id="svgId"></svg>'
}
let
(
:scoped_label
)
{
create
(
:label
,
name:
'key::value'
,
project:
project
,
description:
scoped_description
)
}
context
'with scoped labels enabled'
do
context
'with scoped labels enabled'
do
before
do
before
do
...
@@ -24,6 +25,10 @@ RSpec.describe Banzai::Filter::LabelReferenceFilter do
...
@@ -24,6 +25,10 @@ RSpec.describe Banzai::Filter::LabelReferenceFilter do
it
'renders HTML tooltips'
do
it
'renders HTML tooltips'
do
expect
(
doc
.
at_css
(
'.gl-label-scoped a'
).
attr
(
'data-html'
)).
to
eq
(
'true'
)
expect
(
doc
.
at_css
(
'.gl-label-scoped a'
).
attr
(
'data-html'
)).
to
eq
(
'true'
)
end
end
it
"escapes HTML in the label's title"
do
expect
(
doc
.
at_css
(
'.gl-label-scoped a'
).
attr
(
'title'
)).
to
include
(
'xss <svg id="svgId">'
)
end
end
end
context
'with a common label'
do
context
'with a common label'
do
...
...
lib/gitlab/markdown_cache.rb
View file @
11a72bc3
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
module
Gitlab
module
Gitlab
module
MarkdownCache
module
MarkdownCache
# Increment this number every time the renderer changes its output
# Increment this number every time the renderer changes its output
CACHE_COMMONMARK_VERSION
=
2
6
CACHE_COMMONMARK_VERSION
=
2
7
CACHE_COMMONMARK_VERSION_START
=
10
CACHE_COMMONMARK_VERSION_START
=
10
BaseError
=
Class
.
new
(
StandardError
)
BaseError
=
Class
.
new
(
StandardError
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment