Form injection in asset-proxy via SVG file added in Issue description can lead to credential stealing
The asset proxy used by GitLab to serve images from issue descriptions does not block form submissions via its Content-Security-Policy, allowing an attacker to host an SVG containing a form on the proxy domain. On self-hosted instances where the proxy is a subdomain of the main domain, password managers may autofill and submit credentials to the attacker.
GitLab
Originally disclosed on GitLab
- Fixed in 8 months
- Disclosed after 8 months
⚠️ Please read the process on how to fix security issues before starting to work on the issue. Vulnerabilities must be fixed in a security mirror.
HackerOne report #2834013 by joaxcar on 2024-11-11, assigned to @greg:
Report | How To Reproduce
Report
Summary
Its possible to configure Gitlab to use a proxy server for image content linked in descriptions and discussions. See docs
Given the docs this example configuration is given:
curl --request "PUT" "https://gitlab.example.com/api/v4/application/settings?\
asset_proxy_enabled=true&\
asset_proxy_url=https://proxy.gitlab.example.com&\
asset_proxy_secret_key=<somekey>" \
--header 'PRIVATE-TOKEN: <my_private_token>'
which would put the proxied requests under the domain https://proxy.gitlab.example.com given an instance on https://gitlab.example.com
The documentation tells users to use go-camo.
Any content proxied through the proxy will be served with "safe headers" and a CSP like this (per default):
Content-Security-Policy: default-src 'none'; img-src data:; style-src 'unsafe-inline'
On gitlab.com the proxy server is on https://user-content.gitlab-static.net/ and is served with the CSP
media-src 'self'; script-src 'none'; object-src 'none'
None of these CSP's will block form actions. This allows a malicious user to host forms on these subdomains.
On gitlab.com, this does not have a great impact as the top domain is gitlab-static.net, but on self-hosted instances that follow the documentation, they might use proxy.toplevel.com instead. Using a subdomain of the main domain will allow most password managers to autofill (and potentially auto-submit) forms as they are usually lax in what domains they hit.
Worst case, it could lead to automatic credential theft; best case, it's a form of injection that could be used for phishing or other activities.
I believe you should make sure that any CSP on these domains are blocking form-actions
Steps to reproduce
To test this on gitlab.com
- Create a new
issuein any project - In the description type this (or any link to your own hosted SVG file with HTML content)
{{media:0}}
- Click create
- When the page loads click on the image that look like a form
- You should end up on a page like
https://user-content.gitlab-static.net/2984931a8e1d4162aa4def42cd42566626b10223/68747470733a2f2f6a6f61786361722e636f6d2f74656d70332e737667containing a form - Fill the form and click
Submitand the form will send your data toexample.com
This just proves that you can store any form of HTML content on the proxy domain, and that forms can be submitted. If you want to test this using password managers you need to follow https://docs.gitlab.com/ee/security/asset_proxy.html to set it up on your local instance under a subdomain of your main instance domain.
What is the current bug behavior?
The proxy endpoints will per default allow HTML in SVGs and be served with a CSP that will not block form actions
What is the expected correct behavior?
Users should not be able to serve interactive forms under the proxy domain
Output of checks
this bug happens on GitLab.com
Impact
HTML injection with form action CSP bypass can potentially leak victims credentials under default configuration
How To Reproduce
Please add reproducibility information to this section:
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the Content-Security-Policy applied to proxied content lacks a `form-action` directive, allowing forms in SVGs to submit data.
Impact
On self-hosted instances where the proxy is a subdomain of the main domain, password managers may autofill and submit forms, potentially leading to credential theft; on gitlab.com the impact is limited because the proxy domain is different.
What the attacker needed
Self-hosted GitLab with asset proxy on a subdomain; victim clicks on a crafted image link; password manager autofills forms
The fix
The Content-Security-Policy on the proxy domain should include a `form-action` directive that blocks form submissions.
How it was found
- Create a new issue in any project.
- In the description, add an image tag pointing to an SVG file that contains HTML form content.
- Click create to save the issue.
- When the page loads, click on the image that looks like a form.
- You are taken to a page on the proxy domain containing the form.
- Fill the form and click Submit; the data is sent to an external site.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
GitLab can be set up to load images through a separate proxy server. That proxy serves files with security rules (CSP) that are meant to stop harmful content, but the rules do not stop HTML forms from working. So an attacker can upload an SVG image that contains a form, and when a victim opens it on the proxy domain, the form can send data to the attacker. On self-hosted GitLab, if the proxy is a subdomain of the main site, password managers might automatically fill in and submit the form with the victim's credentials.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.