Remove `'self'` from `frame-src` in the CSP
Summary
There is a CSP bypass possible when embedding a GitLab-hosted SVG and loading it in an iframe because we allow self
as a source for frames.
Steps to reproduce
This assumes an existing XSS. Inject this script
<iframe src="https://gitlab.com/path/to/a/raw/svg" />
with this SVG
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
version="1.1" baseProfile="full"
width="700px" height="400px" viewBox="0 0 700 400">
<circle cx="125" cy="125" r="75" />
<script type="text/javascript">
alert(window.parent.document.domain)
</script>
</svg>
Example Project
This bypass was used in #219378 (closed)
What is the current bug behavior?
The script in the iframe
is executed
What is the expected correct behavior?
The iframe
shouldn't load the SVG and execute the script
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)
Possible fixes
Remove self
from the CSP and allowlist any paths that we really need to use in an iframe
. There shouldn't be many. I asked in slack a while back and we only found one.
I tried this in !61159 (closed) and the QA tests passed. I didn't have the time to get this to the end back then but I think that MR could be reopened as-is