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
6d360c21
Commit
6d360c21
authored
Aug 23, 2018
by
Fatih Acet
Committed by
André Luís
Sep 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly sanitize JSON data to fix XSS on Issue details page.
parent
c56f2b96
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
4 deletions
+47
-4
app/assets/javascripts/issue_show/index.js
app/assets/javascripts/issue_show/index.js
+4
-3
app/assets/javascripts/pages/projects/issues/show.js
app/assets/javascripts/pages/projects/issues/show.js
+2
-1
changelogs/unreleased/security-acet-issue-details.yml
changelogs/unreleased/security-acet-issue-details.yml
+5
-0
spec/features/issues/issue_detail_spec.rb
spec/features/issues/issue_detail_spec.rb
+17
-0
spec/javascripts/issue_show/index_spec.js
spec/javascripts/issue_show/index_spec.js
+19
-0
No files found.
app/assets/javascripts/issue_show/index.js
View file @
6d360c21
import
Vue
from
'
vue
'
;
import
sanitize
from
'
sanitize-html
'
;
import
issuableApp
from
'
./components/app.vue
'
;
import
'
../vue_shared/vue_resource_interceptor
'
;
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
export
default
function
initIssueableApp
()
{
const
initialDataEl
=
document
.
getElementById
(
'
js-issuable-app-initial-data
'
);
const
props
=
JSON
.
parse
(
initialDataEl
.
innerHTML
.
replace
(
/"/g
,
'
"
'
));
const
props
=
JSON
.
parse
(
sanitize
(
initialDataEl
.
textContent
)
.
replace
(
/"/g
,
'
"
'
));
return
new
Vue
({
el
:
document
.
getElementById
(
'
js-issuable-app
'
),
...
...
@@ -17,4 +18,4 @@ document.addEventListener('DOMContentLoaded', () => {
});
},
});
}
);
}
app/assets/javascripts/pages/projects/issues/show.js
View file @
6d360c21
...
...
@@ -3,9 +3,10 @@ import Issue from '~/issue';
import
ShortcutsIssuable
from
'
~/shortcuts_issuable
'
;
import
ZenMode
from
'
~/zen_mode
'
;
import
'
~/notes/index
'
;
import
'
~/issue_show/index
'
;
import
initIssueableApp
from
'
~/issue_show
'
;
export
default
function
()
{
initIssueableApp
();
new
Issue
();
// eslint-disable-line no-new
new
ShortcutsIssuable
();
// eslint-disable-line no-new
new
ZenMode
();
// eslint-disable-line no-new
...
...
changelogs/unreleased/security-acet-issue-details.yml
0 → 100644
View file @
6d360c21
---
title
:
Sanitize JSON data properly to fix XSS on Issue details page
merge_request
:
author
:
type
:
security
spec/features/issues/issue_detail_spec.rb
View file @
6d360c21
...
...
@@ -18,6 +18,23 @@ describe 'Issue Detail', :js do
end
end
context
'when issue description has xss snippet'
do
before
do
issue
.
update!
(
description:
'![xss" onload=alert(1);//](a)'
)
sign_in
(
user
)
visit
project_issue_path
(
project
,
issue
)
wait_for_requests
end
it
'should encode the description to prevent xss issues'
do
page
.
within
(
'.issuable-details .detail-page-description'
)
do
expect
(
page
).
to
have_selector
(
'img'
,
count:
1
)
expect
(
find
(
'img'
)[
'onerror'
]).
to
be_nil
expect
(
find
(
'img'
)[
'src'
]).
to
end_with
(
'/a'
)
end
end
end
context
'when edited by a user who is later deleted'
do
before
do
sign_in
(
user
)
...
...
spec/javascripts/issue_show/index_spec.js
0 → 100644
View file @
6d360c21
import
initIssueableApp
from
'
~/issue_show
'
;
describe
(
'
Issue show index
'
,
()
=>
{
describe
(
'
initIssueableApp
'
,
()
=>
{
it
(
'
should initialize app with no potential XSS attack
'
,
()
=>
{
const
d
=
document
.
createElement
(
'
div
'
);
d
.
id
=
'
js-issuable-app-initial-data
'
;
d
.
innerHTML
=
JSON
.
stringify
({
initialDescriptionHtml
:
'
<img src=x onerror=alert(1)>
'
,
});
document
.
body
.
appendChild
(
d
);
const
alertSpy
=
spyOn
(
window
,
'
alert
'
);
initIssueableApp
();
expect
(
alertSpy
).
not
.
toHaveBeenCalled
();
});
});
});
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