Page MenuHomePhabricator

CVE-2023-45365: i18n XSS in Citoid Wikibase module
Closed, ResolvedPublicSecurity

Description

NOTE: The affected feature is enabled on Test Wikidata in the production cluster, as well as on Beta Wikidata (but not on production real Wikidata). Only interface admins On Test Wikidata, admins, interface admins and Wikidata staff have the right to edit the relevant messages. (Interface admins can edit common.js anyways, but regular admins can’t.)

If

  • both Citoid and Wikibase are loaded, and
  • $wgWBRepoSettings['enableRefTabs'] is set to true (it’s false by default), and
  • a $wgWBCitoidFullRestbaseURL is configured (e.g. 'https://en.wikipedia.org/api/rest_'),

then the contents of the messages citoid-wb-pendingdialog-message and citoid-wb-pendingdialog-title will be injected into the page HTML by Citoid’s JS when an item is loaded (even if Citoid doesn’t have anything to do yet), without any escaping. If the messages are set to e.g. <script>alert('xss')</script>, either in en.json or in the MediaWiki: namespace, then that alert will fire.

The messages are being used here:

modules/wikibase/wb.CitoidPendingDialog.js
this.waitingPanel = new OO.ui.PanelLayout( { padded: true, expanded: false } );
this.waitingPanel.$element.append( OO.ui.deferMsg( 'citoid-wb-pendingdialog-message' ) );
this.errorPanel = new OO.ui.PanelLayout( { padded: true, expanded: false } );
this.errorPanel.$element.append( OO.ui.deferMsg( 'citoid-wb-pendingdialog-error' ) );

I’m guessing that OO.ui.deferMsg() isn’t supposed to be used like this (though its documentation is pretty sparse imho).

Event Timeline

Lucas_Werkmeister_WMDE renamed this task from i18n XSS in Citoid wikibase module to i18n XSS in Citoid Wikibase module.Jun 23 2023, 2:18 PM
Lucas_Werkmeister_WMDE added a subscriber: Mvolz.

Tagging in @Esanders as he might have a better sense of how these functions are supposed to be used and/or if there's a better alternative.

Proposed patch for review:

I tested it locally and it seems to work as far as I can tell (the message is shown properly, and escaped correctly).

Mstyles subscribed.

I'll take a look at this patch and test locally as well. If things look good I can deploy on Monday.

mmartorana changed the task status from Open to In Progress.Jul 10 2023, 3:20 PM
mmartorana triaged this task as Medium priority.

Proposed patch for review:

I tested it locally and it seems to work as far as I can tell (the message is shown properly, and escaped correctly).

Deployed

@Lucas_Werkmeister_WMDE - Are there some quick reproduction steps to test and confirm that this is fixed on https://test.wikidata.org/? Thanks.

I don’t think so – without the uselang=xss trick from T340201, you could only reproduce this by making edits in the MediaWiki: namespace, which would potentially make the issue visible to a wider audience. To me it seems better to rely on the local testing of the patch.

(I suppose you could, something like, manually edit Citoid’s en.json file on mwdebug1002, rebuild the l10n cache, and then try it out, to avoid leaving traces in the on-wiki history? But that feels very hacky to me.)

Ok, if there's no convenient, non-destructive way to test this in production, then I suppose we'll need to rely on the local testing of the patch. Thanks.

The patch has been released by @Mstyles via https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Citoid/+/962047/ (+ release branches). I guess this task can now be marked resolved?

I assume so, but I’d leave that up to the security team.

mmartorana changed the visibility from "Custom Policy" to "Public (No Login Required)".

Yes, it can be made public soon. We've been waiting on Mitre to get us the CVEs for the next supplemental security release (T340874) (where this issue is included) and we just got those at the end of last week. So the supplemental security release should come out today or tomorrow.

mmartorana renamed this task from i18n XSS in Citoid Wikibase module to CVE-2023-45365: i18n XSS in Citoid Wikibase module.Oct 10 2023, 5:28 PM