Page MenuHomePhabricator

CVE-2024-23176: MassMessage i18n key massmessage-form-page-help allows i18n-xss
Closed, ResolvedPublicSecurity

Description

Steps to reproduce:

  1. Add $wgUseXssLanguage = true; to your LocalSettings.php
  2. Load http://localhost:8080/wiki/Special:MassMessage?uselang=x-xss

Expected behaviour: No alert messages are shown
Observed behaviour: An alert with the text massmessage-form-page-help is shown

Extra information
It seems that the HTMLFormField help field wraps the content in a HtmlArmor even though the description in HtmlForm says:

'help' -- message text for a message to use as a help text.

Ideally, it should be clearer that HTML is not escaped via this HTMLFormField attribute.

To fix this issue, the code should be updated to use the help-message attribute.

Event Timeline

Really it should just use help-message instead of help

Really it should just use help-message instead of help

Good point. Updated the description.

We should also update phan-taint-check MWVisitor::detectHTMLForm to look for this

sbassett changed the task status from Open to In Progress.EditedOct 12 2023, 8:58 PM
sbassett claimed this task.
sbassett triaged this task as Medium priority.
sbassett subscribed.

I believe the security patch should be as simple as:

I believe the security patch should be as simple as:

deployed

mmartorana renamed this task from MassMessage i18n key massmessage-form-page-help allows i18n-xss to CVE-2024-23176: MassMessage i18n key massmessage-form-page-help allows i18n-xss.Jan 17 2024, 4:16 PM

Change 991327 merged by jenkins-bot:

[mediawiki/extensions/MassMessage@REL1_41] SECURITY: Properly escape massmessage-form-page-help by specifying it as a help-message

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

Change 991326 merged by jenkins-bot:

[mediawiki/extensions/MassMessage@REL1_40] SECURITY: Properly escape massmessage-form-page-help by specifying it as a help-message

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

Change 991080 merged by jenkins-bot:

[mediawiki/extensions/MassMessage@master] SECURITY: Properly escape massmessage-form-page-help by specifying it as a help-message

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

mmartorana changed the visibility from "Custom Policy" to "Public (No Login Required)".Jan 17 2024, 5:34 PM

@mmartorana @sbassett I've just noticed that the patch was incorrect as the help-message key value is provided the text of the message and not the message object / message key. This means that the current page does not display the help message.

The help message should have shown underneath the first textbox in this screenshot:

image.png (302×1 px, 36 KB)

When I use the qqx language, you can see the message key wrapped in two sets of parentheses:

image.png (164×1 px, 15 KB)

@mmartorana @sbassett I've just noticed that the patch was incorrect as the help-message key value is provided the text of the message and not the message object / message key. This means that the current page does not display the help message.

Ugh, thanks for catching this. I think it likely just needs to be help-message => massmessage-form-page-help, since help-message keys should be sanitized via parse() in this context. I'll test locally and get a patch up soon, which we can then review, deploy and add as a correction to T347659 and T276237.

Change 991446 had a related patch set uploaded (by SBassett; author: SBassett):

[mediawiki/extensions/MassMessage@master] SECURITY: Use message label instead of sanitized text output for massmessage-form-page-help message

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

Ugh, thanks for catching this. I think it likely just needs to be help-message => massmessage-form-page-help, since help-message keys should be sanitized via parse() in this context. I'll test locally and get a patch up soon, which we can then review, deploy and add as a correction to T347659 and T276237.

I tested and confirmed the above solution locally via MediaWiki docker. It fixes the double-parentheses while still escaping the message (no alert executed when testing with $wgUseXssLanguage = true;). Hopefully we can get the master patch merged soon and then backported to the relevant release branches. And we'll want to pick to 1.42.0-wmf.13 and 1.42.0-wmf.14 or just do an ad-hoc security deploy with the following patch (same as the gerrit patch above):


And then finally update the supplemental release task T347659 and T276237.

Change 991446 merged by jenkins-bot:

[mediawiki/extensions/MassMessage@master] SECURITY: Use message label instead of sanitized text output for massmessage-form-page-help message

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

Change 991548 had a related patch set uploaded (by Dreamy Jazz; author: SBassett):

[mediawiki/extensions/MassMessage@REL1_41] SECURITY: Use message label instead of sanitized text output for massmessage-form-page-help message

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

Change 991549 had a related patch set uploaded (by Dreamy Jazz; author: SBassett):

[mediawiki/extensions/MassMessage@REL1_40] SECURITY: Use message label instead of sanitized text output for massmessage-form-page-help message

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

Ugh, thanks for catching this. I think it likely just needs to be help-message => massmessage-form-page-help, since help-message keys should be sanitized via parse() in this context. I'll test locally and get a patch up soon, which we can then review, deploy and add as a correction to T347659 and T276237.

I tested and confirmed the above solution locally via MediaWiki docker. It fixes the double-parentheses while still escaping the message (no alert executed when testing with $wgUseXssLanguage = true;). Hopefully we can get the master patch merged soon and then backported to the relevant release branches. And we'll want to pick to 1.42.0-wmf.13 and 1.42.0-wmf.14 or just do an ad-hoc security deploy with the following patch (same as the gerrit patch above):


And then finally update the supplemental release task T347659 and T276237.

Thanks. I've +2'd and +2'd backports of this change (the REL1_39 change was a merge conflict, so I've fixed it and +2'd that one instead of backporting this bug fix).

Change 991548 merged by jenkins-bot:

[mediawiki/extensions/MassMessage@REL1_41] SECURITY: Use message label instead of sanitized text output for massmessage-form-page-help message

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

Change 991332 merged by jenkins-bot:

[mediawiki/extensions/MassMessage@REL1_39] SECURITY: Properly escape massmessage-form-page-help by specifying it as a help-message

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

Change 991549 merged by jenkins-bot:

[mediawiki/extensions/MassMessage@REL1_40] SECURITY: Use message label instead of sanitized text output for massmessage-form-page-help message

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

Change 991552 had a related patch set uploaded (by Dreamy Jazz; author: SBassett):

[mediawiki/extensions/MassMessage@wmf/1.42.0-wmf.14] SECURITY: Use message label instead of sanitized text output for massmessage-form-page-help message

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

I've created a backport for it for wmf.14 and will deploy it now.

Mentioned in SAL (#wikimedia-operations) [2024-01-18T12:07:52Z] <Dreamy_Jazz> Doing security deploy for T347742

Change 991552 merged by jenkins-bot:

[mediawiki/extensions/MassMessage@wmf/1.42.0-wmf.14] SECURITY: Use message label instead of sanitized text output for massmessage-form-page-help message

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

Mentioned in SAL (#wikimedia-operations) [2024-01-18T12:18:45Z] <dreamyjazz@deploy2002> Started scap: Backport for [[gerrit:991552|SECURITY: Use message label instead of sanitized text output for massmessage-form-page-help message (T347742)]]

Mentioned in SAL (#wikimedia-operations) [2024-01-18T12:20:38Z] <dreamyjazz@deploy2002> dreamyjazz: Backport for [[gerrit:991552|SECURITY: Use message label instead of sanitized text output for massmessage-form-page-help message (T347742)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2024-01-18T12:27:13Z] <dreamyjazz@deploy2002> Finished scap: Backport for [[gerrit:991552|SECURITY: Use message label instead of sanitized text output for massmessage-form-page-help message (T347742)]] (duration: 08m 28s)

Mentioned in SAL (#wikimedia-operations) [2024-01-18T12:27:30Z] <Dreamy_Jazz> Finished security deploy for T347742

Hey @Dreamy_Jazz - Thanks for all of the work on this and getting the backports done and the update deployed. Thankfully this fix only needs to live in Wikimedia production until next week's train. I'll go ahead and update T347659 and T276237 now.