Page MenuHomePhabricator

CVE-2025-11261: Stored i18n XSS exposed by security patch for T402077
Closed, ResolvedPublicSecurity

Description

While fixing the tests for https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CheckUser/+/1193254, which is the patch for T402077, I noticed that there is another i18n XSS vulnerability caused by passing a list of HTML strings to mw.language.listToText and using the result as raw HTML.
mw.language.listToText is supposed to be used for text and not HTML, as the return value contains the unsanitized system messages and, word-separator and comma-separator:
https://gerrit.wikimedia.org/g/mediawiki/core/+/ffd25a424f9fc8cbb32a403969e473da85c4389f/resources/src/mediawiki.language/mediawiki.language.js#147

The reproduction steps should be the same as described in T402077, but instead of using uselang=x-xss or editing MediaWiki:checkuser-tempaccount-specialblock-ips, the messages and, word-separator or comma-separator have to be edited to <img src="" onerror="alert(1)">, which should cause an alert.

Event Timeline

This affects master and REL1_44.

I'm not sure what would be the best way to fix this, apart from copying mw.language.listToText into a new method in CheckUser and then escaping the messages so it can be used to produce HTML.

I'm not sure what would be the best way to fix this, apart from copying mw.language.listToText into a new method in CheckUser and then escaping the messages so it can be used to produce HTML.

That seems hacky and would likely cause tech debt if the MediaWiki core version of mw.language.listToText is updated.

Could we not consider adding a XSS safe mw.language.listToText or fixing the issue in that method? AFAICS we would want to use it elsewhere that this issue might occur

While I may have missed something, it seems that there is no need for the listToText messages to use any HTML and so AFAICS we should be able to make them use mw.message( '...' ).escaped() in the current version?

I'm not sure what would be the best way to fix this, apart from copying mw.language.listToText into a new method in CheckUser and then escaping the messages so it can be used to produce HTML.

That seems hacky and would likely cause tech debt if the MediaWiki core version of mw.language.listToText is updated.

Could we not consider adding a XSS safe mw.language.listToText? AFAICS we would want to use it elsewhere that this issue might occur

That's a better solution, I can create a patch for this

I'm not sure what would be the best way to fix this, apart from copying mw.language.listToText into a new method in CheckUser and then escaping the messages so it can be used to produce HTML.

That seems hacky and would likely cause tech debt if the MediaWiki core version of mw.language.listToText is updated.

Could we not consider adding a XSS safe mw.language.listToText? AFAICS we would want to use it elsewhere that this issue might occur

That's a better solution, I can create a patch for this

Thanks for working on this issue

@Dreamy_Jazz actually couldn't we just escape the messages in the existing listToText method instead? The PHP version does the same: https://gerrit.wikimedia.org/g/mediawiki/core/+/ffd25a424f9fc8cbb32a403969e473da85c4389f/includes/language/Language.php#3665
And I don't think and, word-separator or comma-separator should contain any characters that would be double escaped

@Dreamy_Jazz actually couldn't we just escape the messages in the existing listToText method instead? The PHP version does the same: https://gerrit.wikimedia.org/g/mediawiki/core/+/ffd25a424f9fc8cbb32a403969e473da85c4389f/includes/language/Language.php#3665
And I don't think and, word-separator or comma-separator should contain any characters that would be double escaped

Yeah, I edited my comment above to say that AFAICS it should be possible to do that just after you posted your reply

I'd support an approach that just fixes mw.language.listToText. It doesn't seem intentional that they are not escaped. Additionally, I'd expect any callers to escape the items in the list before passing it to this method (so any double escaping issues caused by such a change would be easily fixed)

Reedy triaged this task as High priority.Oct 3 2025, 12:35 PM

Moving to 'Done' on our board, as I've given the patch a review. Can leave the rest to the Security-Team.

Reedy added a subtask: Restricted Task.Oct 3 2025, 1:05 PM
Reedy added a subscriber: gerritbot.
Reedy renamed this task from Stored i18n XSS caused by security patch for T402077 to CVE-2025-11261: Stored i18n XSS caused by security patch for T402077.Oct 3 2025, 1:08 PM

Change #1193414 had a related patch set uploaded (by Reedy; author: SomeRandomDeveloper):

[mediawiki/core@master] SECURITY: Escape system messages in mw.language.listToText

https://gerrit.wikimedia.org/r/1193414

Reedy renamed this task from CVE-2025-11261: Stored i18n XSS caused by security patch for T402077 to CVE-2025-11261: Stored i18n XSS exposed by security patch for T402077.Oct 3 2025, 1:15 PM

Stored i18n XSS exposed by security patch for T402077

I keep forgetting that parameters aren't escaped either when using mw.msg... so that vulnerability was actually already present before

Change #1193414 merged by jenkins-bot:

[mediawiki/core@master] SECURITY: Escape system messages in mw.language.listToText

https://gerrit.wikimedia.org/r/1193414

Change #1193426 had a related patch set uploaded (by Reedy; author: SomeRandomDeveloper):

[mediawiki/core@REL1_44] SECURITY: Escape system messages in mw.language.listToText

https://gerrit.wikimedia.org/r/1193426

Change #1193428 had a related patch set uploaded (by Reedy; author: SomeRandomDeveloper):

[mediawiki/core@REL1_43] SECURITY: Escape system messages in mw.language.listToText

https://gerrit.wikimedia.org/r/1193428

Change #1193429 had a related patch set uploaded (by Reedy; author: SomeRandomDeveloper):

[mediawiki/core@REL1_39] SECURITY: Escape system messages in mw.language.listToText

https://gerrit.wikimedia.org/r/1193429

Change #1193429 merged by jenkins-bot:

[mediawiki/core@REL1_39] SECURITY: Escape system messages in mw.language.listToText

https://gerrit.wikimedia.org/r/1193429

Change #1193428 merged by jenkins-bot:

[mediawiki/core@REL1_43] SECURITY: Escape system messages in mw.language.listToText

https://gerrit.wikimedia.org/r/1193428

Change #1193426 merged by jenkins-bot:

[mediawiki/core@REL1_44] SECURITY: Escape system messages in mw.language.listToText

https://gerrit.wikimedia.org/r/1193426

SomeRandomDeveloper claimed this task.

I assume this can be closed now since it was part of 1.44.2

sbassett changed the visibility from "Custom Policy" to "Public (No Login Required)".
sbassett changed the edit policy from "Custom Policy" to "All Users".
sbassett changed Risk Rating from N/A to Medium.