HTML injection in Wiki templates allows attacker to leak autofill passwords
The wiki template dropdown did not escape template names, allowing an attacker to inject an input field that Chrome's password manager would autofill with the victim's GitLab password. When the victim submitted the form, the password became the wiki page title and was stored in the wiki git log, enabling the attacker to exfiltrate it.
GitLab
Originally disclosed on GitLab
- Fixed in 28 hours
- Disclosed after 28 hours
⚠️ 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 #2430261 by joaxcar on 2024-03-21, assigned to @cmaxim:
Report | How To Reproduce
Report
Summary
GitLab 16.10 shipped with Wiki Templates. Users can create wiki templates in a project that other users can select when creating a wiki page. https://docs.gitlab.com/ee/user/project/wiki/index.html#wiki-page-templates
The dropdown that lists the templates in the wiki creation page does not escape the template names. The names are sanitized, so there is not a lot an attacker can do, but I noticed that I can add an input tag looking like this <input type=password name=wiki[title]>. This will render in the template dropdown (even if the dropdown is not expanded, and it will get auto-filled by Chrome if the user is using Chrome password manager.
When the victim fills out the form as usual and submits it, the password field will overwrite the title of the wiki page and create the wiki with the user's password in plain text. This will be stored in the wiki git log, so removing it is not trivial, and the attacker can exfiltrate it.
Steps to reproduce
- Create a project where two users are members (minimum developers)
- As the attacker go to https://gitlab.com/GROUP/PROJECT/-/wikis/templates and create a new template. Name it
<input type=password name=wiki[title]>
-
Click create
-
As the victim go to chrome://password-manager/passwords in chrome and make sure you add credentials for
gitlab.com -
Now go to https://gitlab.com/GROUP/PROJECT/-/wikis and click "new page"
-
Fill out the form, don't open the templates dropdown
-
Click create
-
Your password should now be the title of the created wiki page
Impact
Leaking user passwords, leading to account takeover
What is the current bug behavior?
Template names are not sanitized
What is the expected correct behavior?
Template names should be sanitized
Output of checks
This bug happens on GitLab.com
Impact
Leaking user passwords, leading to account takeover
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 template names were not HTML-escaped when rendered in the dropdown, allowing injection of an input element.
Impact
Leaking user passwords could lead to account takeover.
What the attacker needed
Attacker and victim are project members; victim uses Chrome password manager; victim has saved GitLab credentials
The fix
Template names should be sanitized.
How it was found
- Create a project with two users as members (minimum developers).
- As the attacker, go to the wiki templates page and create a new template named with an HTML input tag.
- Click create.
- As the victim, ensure Chrome has saved credentials for gitlab.com.
- Go to the project wiki and click 'new page'.
- Fill out the form without opening the templates dropdown and click create.
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 wiki template is a pre-made page layout. The dropdown listing these templates did not properly clean up the template names, so an attacker could put a fake password box in the list. Chrome's password manager would automatically fill that box with the user's saved GitLab password, and when the user created a page, the password was saved as the page title where the attacker could read it.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.