BMO: Persistent XSS via Git commit messages in comments
A format hook in Bugzilla's comment system failed to escape HTML in Git commit messages, allowing an attacker to inject JavaScript that executes when a comment is viewed or previewed.
Originally disclosed on Mozilla
- Fixed in 4 hours
- Paid in 3 days
- Disclosed after 4 hours
BMO comments linkify Git commit messages like the following:
To https://github.com/foobar.git
1234..4321 master -> master
This is implemented as a format hook in extensions/BMO/Extension.pm. Format hooks run before HTML entities are escaped in the text and are responsible for escaping their results themselves - this particular hook fails to do it. So the following text in a comment will run JavaScript code:
> To https://github.com/foobar.git
> 1234..4321 master<iframe/onload=alert(document.domain)> -> master
Note that I quoted the text here to make sure the hook isn't triggered. Without quoting it would display an alert saying "bugzilla.mozilla.org". You don't need to create a new bug in order to test this, entering the text into a comment and switching to the preview tab will already display the alert.
Note that there are two branches in the code processing Git commit messages (github.com and git.mozilla.org). Both of them are vulnerable and the following text will trigger the bug in the other branch:
> To [address removed]/foobar.git
> 1234..4321 master<iframe/onload=alert(document.domain)> -> master
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 format hook responsible for linkifying Git commit messages did not escape HTML entities in its output.
Impact
An attacker could execute arbitrary JavaScript in the context of the Bugzilla domain, potentially stealing session cookies or performing actions on behalf of the victim.
What the attacker needed
Ability to post a comment; victim views the comment or preview
How it was found
- Enter a comment containing a Git commit message with an iframe onload payload.
- Switch to the preview tab to see the alert, or submit the comment for persistent execution.
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 you type a comment, the website usually converts special characters like < and > into safe text so they can't run code. Here, a feature that automatically links Git commit messages forgot to do that conversion, so an attacker could include a script that runs in the browser of anyone who views the comment.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.