[Bypass] 1-click account takeover via XSS in the code editor in gitlab.com (bypass of CVE-2024-4835)
The fix for a previous XSS vulnerability in a GitLab-hosted HTML file could be bypassed by adding an extra query parameter, allowing an attacker to set a malicious parentOrigin and execute JavaScript in the gitlab.com origin. This enabled one-click account takeover by stealing the victim's API token and adding a new token to their account.
GitLab
Originally disclosed on GitLab
- Fixed in 16 days
- Disclosed after 16 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 #2517090 by matanber on 2024-05-23:
Report | How To Reproduce
Report
Summary
In report #2497024, I exploited the 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 order to get XSS in the gitlab.com origin. This was done by making the victim navigate to the file, with a malicious origin in the parentOrigin query parameter. Judging by the new behavior of this page, the fix that was implemented for that report involves checking intercepting every request to the vulnerable HTML file, and blocking it if the string parentOrigin=https://gitlab.com doesn't exist in it's URL. This fix is supposed to ensure that the value of the parentOrigin parameter is always set to https://gitlab.com and not to a malicious origin, but it fails to do so, as a request to a URL such as the following would not be blocked:
https://gitlab.com/assets/webpack/gitlab-vscode/0.0.1-dev-20240501001436/vscode/out/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.html?&vscodeWebWorkerExtHostId=a&parentOrigin=https://peo.si&bparentOrigin=https://gitlab.com
Because an attacker can use a URL of that form to specify a parentOrigin parameter with a malicious value, the fix can be bypassed, and the attack described in report #2497024 can be performed.
Steps to reproduce
- As the victim, log in to your account in gitlab.com.
- Navigate to https://peo.si/gl/editor/bypass-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?
A URL of the form https://gitlab.com/assets/webpack/gitlab-vscode/0.0.1-dev-20240501001436/vscode/out/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.html?&vscodeWebWorkerExtHostId=a&parentOrigin=https://malicious.com is blocked, but a URL of the form https://gitlab.com/assets/webpack/gitlab-vscode/0.0.1-dev-20240501001436/vscode/out/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.html?&vscodeWebWorkerExtHostId=a&parentOrigin=https://malicious.com&bparentOrigin=https://gitlab.com is not.
What is the expected correct behavior?
Any URL with a parentOrigin URL parameter which does not have a value of https://gitlab.com should be blocked.
Output of checks
This bug happens on GitLab.com
Impact
An attacker can take over a victim's GitLab account, with a single click (a navigation) from the victim.
This impact is identical to the impact described in report #2497024.
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 fix used a naive substring check on the URL instead of properly parsing and validating the parentOrigin parameter, so an attacker could add a second parameter containing the required string.
Impact
An attacker can take over a victim's GitLab account with a single click (a navigation) from the victim.
What the attacker needed
Victim is logged in to gitlab.com; victim clicks a link
The fix
The URL check should properly parse the parentOrigin parameter and block any request where its value is not exactly https://gitlab.com.
How it was found
- As the victim, log in to your account in gitlab.com.
- Navigate to the attacker's page that loads the vulnerable GitLab HTML file with a crafted URL.
- Observe the API token logged in the browser console.
- Check the personal access tokens page and see the malicious 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 security fix tried to block malicious links to a special GitLab web page by checking for a specific string in the URL. The attacker found a way to include that string while still controlling another part of the URL, so the page ran their code. This let them steal the victim's login token and take over the account with one click.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.