1-click account takeover via XSS in the code editor in gitlab.com
The webWorkerExtensionHostIframe.html file, hosted on the gitlab.com origin, did not validate the origin of postMessage events. A malicious site could embed this iframe and send crafted messages to load an arbitrary JavaScript file as an extension, leading to code execution in the gitlab.com origin and account takeover.
GitLab
Originally disclosed on GitLab
- Fixed in 9 days
- Disclosed after 9 days
⚠️ 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 #2497024 by matanber on 2024-05-09, assigned to @ottilia_westerlund:
Report | How To Reproduce
Report
Summary
Like in every web-based VS Code instance, the web page for the GitLab Web IDE includes a "webWorkerExtensionHostIframe.html" file (hosted at https://gitlab.com/assets/webpack/gitlab-vscode/0.0.1-dev-20240501001436/vscode/out/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.html) in an iframe. This iframe is responsible for running VS Code extensions, and it communicates with its parent window via postMessages. However, the postMessage listener in this iframe does not properly validate the origin of the messages which it receives. This allows a malicious site to include the webWorkerExtensionHostIframe.html file in an iframe and interact with it as if it was the web page for the web IDE. This site can then instruct the extension host to load an arbitrary JS file as an extension, leading to arbitrary JS code execution in the https://gitlab.com origin.
In order to exploit this issue, I logged all of the messages which are normally sent to the extension host by the page, and then modified the content of one of the messages which includes an object representing the URL of the JS file of the gitlab-ide extension, and modified the object so that it represents the URL of a malicious JS file (https://peo.si/gl/editor/include.js). Then, I created a PoC page hxxps://peo.si/gl/editor/poc-frame.html which simply sends all of the messages in the log file in sequence.
Steps to reproduce
- As the victim, log in to your account in gitlab.com.
- Navigate to
hxxps://peo.si/gl/editor/poc-frame.html - Notice the API token which was logged in the console.
- Navigate to https://gitlab.com/-/user_settings/personal_access_tokens, and notice the malicious API token which was added to your account.
What is the current bug behavior?
The webWorkerExtensionHostIframe.html file is hosted in the https://gitlab.com origin.
What is the expected correct behavior?
The webWorkerExtensionHostIframe.html file should be hosted in a unique sandbox origin. This is the behavior which exists in the vscode.dev and github.dev web-based VS Code instances.
Output of checks
This bug happens on GitLab.com
Impact
An attacker can take over a victim's GitLab account, with a single click from the victim.
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
Impact
An attacker could take over a victim's GitLab account with a single click from the victim.
What the attacker needed
Victim is logged in to gitlab.com; victim visits attacker's page
The fix
The webWorkerExtensionHostIframe.html file should be hosted in a unique sandbox origin, as done by vscode.dev and github.dev.
How it was found
- As the victim, log in to your account in gitlab.com.
- Navigate to the attacker's proof-of-concept page.
- Notice the API token which was logged in the console.
- Navigate to the personal access tokens settings page and notice the malicious API token added to the account.
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.
A web page can send messages to another page it contains in an iframe. If the receiving page does not check who sent the message, a malicious site can pretend to be the real site and make the iframe run harmful code. Here, that allowed the attacker to run code as if it were gitlab.com and steal the user's account.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.