HTML injection in code navigation leads to ATO
A previous fix for an HTML injection in GitLab's code navigation only sanitised data with DOMPurify's default configuration, which the reporter says can be bypassed. By injecting markup through the code navigation response, an attacker could use script gadgets in data attributes to achieve account takeover.
GitLab
Originally disclosed on GitLab
- Fixed in 27 days
- Disclosed after 27 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 #3297413 by joaxcar on 2025-08-13, assigned to @katwu:
Report | Attachments | How To Reproduce
Report
Summary
Hi I saw that there is a patch for #3247096 in version 18.2.2. See MR here https://gitlab.com/gitlab-org/security/gitlab/-/merge_requests/5203 (private)
and commit here: https://gitlab.com/gitlab-org/gitlab/-/commit/61f1c480da2916cd20eb82f1ae4ba8b0b96029c6
The fix only sanitizes the data using the Gitlab default configuration for DOMPurify, which I have proven before can be bypassed. This fix will prevent full XSS that was previously possible but still allow for ATO using script gadgets through data attributes
See my comments in #3247096 on how the root cause for the issue here is that you take the textContent of one element and put this into innerHTML of another element
wrapNodes(elm.textContent ...)
...
wrapper.innerHTML = wrapSpacesWithSpans(text);
This is problematic as textContent will convert HTML entities to HTML. You should probably just do elm.innerHTML in the first step as well, this will keep all entities as entities
(NOTE see the previous report for technical info on how this could be abused without the "override" in the POC, I can copy paste it over here if needed, but I think this keeps it cleaner)
Steps to reproduce
see #3247096 for details on how the full flow works and why we need to use an override in devtools. This is just to be able to prove the point here
Do this in Chrome!
- Import this project
- Go to the project and trigger a new pipeline manually
- Go to the project and click on the
xss.pyfile. - now open devtools and go to the
Networktab - Refresh the page
- You will see a call to
*something*....?file_type=lsifright click this call and pick Overwrite Content - There will be a small pop-up asking you where to store the Chrome override files, pick any directory
- Now in the small editor that opens, delete all text that is there and replace it with
[{"start_line":0,"start_char":1,"definition_path":"hej.py#L5","hover":[{"value":""}]}]
Click ctrl-s to save
9. Refresh the page again (with devtools still open)\
The string in the Python file should now disappear and be replaced by a big gray square.
10.Click the gray square
11. A new page will open, wait for about 15 seconds for the page to close again
12. Now click the gray square again, nothing will happen
13. Go to https://gitlab.com/-/profile/emails and see that you have a new email on your account.
14. Remove the email so that others can test it
<video redacted>
Impact
HTML injection leads to full ATO
What is the current bug behavior?
The fix use sanatize from DOMPurify which can still be bypassed in some situations
What is the expected correct behavior?
There is point in using textContent an the text should never contain HTML. Thus its better to use innerHTML to also get the text out of the element. This will prevent all injections
Output of checks
This bug happens on GitLab.com
Impact
HTML injection leads to full ATO
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
- xss_bypas.tar.gz
- <redacted>
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
The code reads an element's textContent and writes it into another element's innerHTML, so HTML entities in the text are decoded and become live markup.
Impact
HTML injection could lead to full account takeover, though the proof of concept needed a devtools response override to demonstrate it.
What the attacker needed
Chrome browser; devtools response override used in the proof of concept
The fix
The code should read the element's innerHTML instead of textContent so entities stay encoded and no markup is injected.
How it was found
- Import the provided project archive.
- Trigger a new pipeline manually in the project.
- Open the xss.py file in the project.
- In Chrome devtools, open the Network tab and refresh the page.
- Find the request with file_type=lsif and use Overwrite Content to replace its response with crafted JSON.
- Refresh again, click the grey square, wait for the page to close, then click it again and check the profile emails page.
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.
When a web page inserts text into itself, it must treat that text as plain text, not as code. Here the page took text from one place and inserted it as HTML into another, so crafted content could run as a script. The earlier fix tried to clean the content but used a cleaner that can be tricked, letting an attacker add an email address to a victim'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.