Page MenuHomePhabricator

XSS in GlobalWatchlist (CVE-2021-42046)
Closed, ResolvedPublic2 Estimated Story PointsSecurity

Description

As I was reviewing existing code in a different context, I realized that we don't escape the uses of mw.msg in watchlistUtils.makeUserLinks, which returns raw html. This can create an XSS if the messages rev-deleted-user or ntimes are manipulated to try and include scripts.

The solution is to add mw.html.escape() calls or use mw.Message.escaped()
Given that this hasn't (as far as I can tell) been noticed anywhere, and there will be a bunch of unrelated changes to the relevant file that may cause merge conflicts if the fix is deployed as a normal security patch, would it be okay to send this publicly on gerrit? Commit message would be along the lines of "Clean up watchlistUtils.makeUserLinks" and I would replace the mw.msg() shortcut with creation of mw.Message objects and calling .escaped().

Relevant code is at https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/GlobalWatchlist/+/141326cdcce048b2b764fdd00181c123463572ab/modules/watchlistUtils.js#84

You can confirm by setting the message rev-deleted-user to (username removed)</span><script>alert('error')</script><span>

Related Objects

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
sbassett added a project: SecTeam-Processed.
sbassett added a subscriber: sbassett.

... would it be okay to send this publicly on gerrit? Commit message would be along the lines of "Clean up watchlistUtils.makeUserLinks"

Yes, issues like this are generally fine to push through gerrit, since several similar issues have been fixed publicly under T2212. If you'd like, we can keep this bug private for now (even though the patch would obviously disclose the issue) and maybe deploy this sooner via a backport window if it misses this week's train.

Change 703903 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/GlobalWatchlist@master] Clean up to watchlistUtils.makeUserLinks

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

Change 703903 merged by jenkins-bot:

[mediawiki/extensions/GlobalWatchlist@master] Clean up to watchlistUtils.makeUserLinks

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

... would it be okay to send this publicly on gerrit? Commit message would be along the lines of "Clean up watchlistUtils.makeUserLinks"

Yes, issues like this are generally fine to push through gerrit, since several similar issues have been fixed publicly under T2212. If you'd like, we can keep this bug private for now (even though the patch would obviously disclose the issue) and maybe deploy this sooner via a backport window if it misses this week's train.

It missed this week's train, do we want to backport it?

Also, should this be backported to 1.36? I would say no - we should only maintain the MASTER branch of GlobalWatchlist and not any of the prior releases because its mostly intended to be used by WMF wikis

Change 704378 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/GlobalWatchlist@master] Fix creation of mw.Message objects

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

Change 704378 merged by jenkins-bot:

[mediawiki/extensions/GlobalWatchlist@master] Fix creation of mw.Message objects

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

It missed this week's train, do we want to backport it?

Can we try to get it scheduled for tomorrow's backport window?

Also, should this be backported to 1.36? I would say no - we should only maintain the MASTER branch of GlobalWatchlist and not any of the prior releases because its mostly intended to be used by WMF wikis

As the official maintainer of the extension, I suppose the final call is up to you. I would note that the Security-Team generally prefers to backport security-related issues to any relevant release branches regardless of their overall/actual usage outside of Wikimedia production.

It missed this week's train, do we want to backport it?

Can we try to get it scheduled for tomorrow's backport window?

I should be able to be around. Note that there are two patches - the first accidentally broke things and the second fixed it properly. They would need to be deployed together.

Also, should this be backported to 1.36? I would say no - we should only maintain the MASTER branch of GlobalWatchlist and not any of the prior releases because its mostly intended to be used by WMF wikis

As the official maintainer of the extension, I suppose the final call is up to you. I would note that the Security-Team generally prefers to backport security-related issues to any relevant release branches regardless of their overall/actual usage outside of Wikimedia production.

In that case, I have no objection to back porting them both to 1.36 (there is no 1.35 branch or earlier). Should we wait until closer to the security release of 1.36.2 to avoid calling attention to the fact that this was a security issue?

I should be able to be around. Note that there are two patches - the first accidentally broke things and the second fixed it properly. They would need to be deployed together.

Should be fine, just need to get them added to the schedule, I believe. If that doesn't happen, I can sec-deploy them, but I'd rather not if we can get them pushed during a backport window.

In that case, I have no objection to back porting them both to 1.36 (there is no 1.35 branch or earlier). Should we wait until closer to the security release of 1.36.2 to avoid calling attention to the fact that this was a security issue?

We can. Since GlobalWatchlist isn't bundled and the issue is already quasi-disclosed via gerrit, I'll track it on the next supplemental announcement task: T285414

You can test this in your browser to confirm the security fix without changing the sitewide mediawiki messages by, if you have an entry with the user revision deleted, running mw.messages.set( 'rev-deleted-user', "(username removed)</span><script>alert('error')</script><span>" ); in the console and then refreshing

Change 704814 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/GlobalWatchlist@wmf/1.37.0-wmf.14] Clean up to watchlistUtils.makeUserLinks

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

Change 704815 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/GlobalWatchlist@wmf/1.37.0-wmf.14] Fix creation of mw.Message objects

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

Change 704814 merged by jenkins-bot:

[mediawiki/extensions/GlobalWatchlist@wmf/1.37.0-wmf.14] Clean up to watchlistUtils.makeUserLinks

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

DannyS712 edited subscribers, added: Stashbot; removed: Stashbot.

Change 704815 merged by jenkins-bot:

[mediawiki/extensions/GlobalWatchlist@wmf/1.37.0-wmf.14] Fix creation of mw.Message objects

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

Mentioned in SAL (#wikimedia-operations) [2021-07-15T23:28:53Z] <brennen@deploy1002> Synchronized php-1.37.0-wmf.14/extensions/GlobalWatchlist/modules/watchlistUtils.js: Backport: [[gerrit:704815|Fix creation of mw.Message objects (T286385)]] (duration: 00m 57s)

DannyS712 moved this task from In progress to Done on the MediaWiki-extensions-GlobalWatchlist board.
DannyS712 changed Author Affiliation from N/A to Wikimedia Communities.
DannyS712 set the point value for this task to 2.
DannyS712 moved this task from Next to In progress on the User-DannyS712 board.

Okay, fixed in master and backported to current wmf branch (1.37.0-wmf.14), needs backport to 1.36 as part of T285414: Write and send supplementary release announcement for extensions and skins with security patches (1.31.16/1.35.4/1.36.2) but other than that this should be done, right? Should we keep it open until the 1.36 backport? Or is it okay to close as resolved?

sbassett triaged this task as Low priority.EditedJul 20 2021, 2:06 AM
sbassett moved this task from Our Part Is Done to Watching on the Security-Team board.

... but other than that this should be done, right? Should we keep it open until the 1.36 backport? Or is it okay to close as resolved?

  1. Yes, save the 1.36 backport and disclosure via the supplemental security announcement.
  2. I think we usually do this so as to avoid confusion as to whether the issue is completely resolved.
  3. If you really want to resolve it, we can, but I'd rather keep this open to avoid confusion. You can certainly resolve it on your user board.

... but other than that this should be done, right? Should we keep it open until the 1.36 backport? Or is it okay to close as resolved?

  1. Yes, save the 1.36 backport and disclosure via the supplemental security announcement.
  2. I think we usually do this so as to avoid confusion as to whether the issue is completely resolved.
  3. If you really want to resolve it, we can, but I'd rather keep this open to avoid confusion. You can certainly resolve it on your user board.

Thanks for explaining, will leave open

Change 725282 had a related patch set uploaded (by Mstyles; author: DannyS712):

[mediawiki/extensions/GlobalWatchlist@REL1_36] Clean up to watchlistUtils.makeUserLinks

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

Change 725282 abandoned by Mstyles:

[mediawiki/extensions/GlobalWatchlist@REL1_36] Clean up to watchlistUtils.makeUserLinks

Reason:

wrong order

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

Change 725282 restored by SBassett:

[mediawiki/extensions/GlobalWatchlist@REL1_36] Clean up to watchlistUtils.makeUserLinks

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

Change 725282 merged by jenkins-bot:

[mediawiki/extensions/GlobalWatchlist@REL1_36] Clean up to watchlistUtils.makeUserLinks

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

sbassett changed the visibility from "Custom Policy" to "Public (No Login Required)".Oct 4 2021, 7:15 PM
sbassett changed the edit policy from "Custom Policy" to "All Users".
sbassett changed Risk Rating from N/A to Low.
sbassett moved this task from Watching to Our Part Is Done on the Security-Team board.
sbassett removed a project: Patch-For-Review.

Change 725920 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/GlobalWatchlist@REL1_36] Fix creation of mw.Message objects

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

Change 725920 merged by jenkins-bot:

[mediawiki/extensions/GlobalWatchlist@REL1_36] Fix creation of mw.Message objects

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

Ok, now merged, thanks. And also tracked for the supplemental (T285414), which will be released within a couple of days.

Moving back to resolved since the backport was merged

Mstyles renamed this task from XSS in GlobalWatchlist to XSS in GlobalWatchlist (CVE-2021-42046).Oct 7 2021, 8:33 PM