XSSI on Gitlab Pages
A bypass of a previous fix for cross-site script inclusion (XSSI) allowed an attacker to steal JavaScript content from private GitLab Pages by using a group with a namespace that is a subdomain of the victim's page domain. An attacker could read sensitive data from a private page if the victim visited the attacker's page while authenticated.
GitLab
Originally disclosed on GitLab
- Fixed in 8 months
- Disclosed after 8 months
HackerOne report #1842148 by shells3c on 2023-01-20, assigned to GitLab Team:
Report | How To Reproduce
Report
Summary
This is a bypass of #719770, the export of the report can be found here: https://gitlab.com/gitlab-org/gitlab-pages/-/issues/264
XSSI was basically fixed in #719770, a script can no longer be included from any website other than the Gitlab page that contains the script file itself. However, I found a bypass for this, using a group with the namespace sub.<username>
Steps to reproduce
- As the victim, create a Gitlab Page, you can fork the example project for testing here
- Make the page private, by changing the project visibility to private or just changing the page visibility to Only Project Members in the General Settings
- Create a javascript file, let say
secret.jswith the following content:
secret="THIS IS MY SECRET";
(If you used the example project, the file would locate inside the public/ folder)
4. As the attacker, create a group with the name: xssi.<victim>, create a Gitlab page inside that group using the same steps you used previously, then edit the index file (or you can create another file if you want) with the following content:
<!DOCTYPE html>
<html>
<head>
<script src="https://<victim>.gitlab.io/secret.js"></script>
</head>
<body>
<script>alert(secret)</script>
</body>
</html>
- As the victim again, visit the page to authenticate and see the javascript content:
https://<victim>.gitlab.io/secret.js - Now visit the attacker page, if you used the example project and edited
index.html, just visithttps://xssi.<victim>.gitlab.io/plain-htmland you will see the secret pop up
If you try to use the same method to steal the secret using another domain (<your username>.gitlab.io for example), it won't work
Output of checks
This bug happens on GitLab.com
Impact
Stealing javascript content of private Gitlab pages, also known as XSSI
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 XSSI protection relied on checking the origin of the script request, but the check was bypassed because the attacker's page was hosted on a subdomain of the victim's domain, which was considered same-origin.
Impact
An attacker could steal JavaScript content from private GitLab Pages, potentially exposing sensitive information, if the victim visited the attacker's page while authenticated.
What the attacker needed
Victim has a private GitLab Page; victim visits attacker's page while authenticated; attacker can create a group with a specific name
How it was found
- As the victim, create a GitLab Page (e.g., fork the example project).
- Make the page private by changing project visibility to private or page visibility to 'Only Project Members'.
- Create a JavaScript file (e.g., secret.js) containing a secret variable.
- As the attacker, create a group named 'xssi.<victim>' and create a GitLab Page in that group.
- Edit the attacker's page to include a script tag loading the victim's secret.js and then alert the secret.
- As the victim, visit the victim's page to authenticate, then visit the attacker's page to see the secret pop up.
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.
XSSI is a flaw where a malicious website can include a script from another site and read its contents. A previous fix stopped this, but a loophole let an attacker's page on a similar-looking domain load the victim's private script.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.