The masseditregex-before and masseditregex-after system messages are inserted into raw HTML by the MassEditRegex extension, allowing for stored XSS by inserting malicious HTML into the messages.
Reproduction steps
- Clone https://gerrit.wikimedia.org/r/c/mediawiki/extensions/MassEditRegex/+/1160772 to get the extension working on MW >1.44, or use an MW version between 1.40-1.43 for testing this
- Edit MediaWiki:Masseditregex-before to Before<script>alert('before')</script>
- Edit MediaWiki:Masseditregex-after to After<script>alert('after')</script>
- Go to Special:MassEditRegex, enter any existing page into the "Pages to edit:" field and click "Show preview"
Cause
The system messages are retrieved using the text output mode, which does not sanitize them, concatenated with HTML and inserted into diffEngine->getDiff via the $otitle and $ntitle parameters, which are inserted as raw HTML.

