Page MenuHomePhabricator

CVE-2025-53486: Reflected XSS in WikiCategoryTagCloud
Closed, ResolvedPublicSecurity

Description

The WikiCategoryTagCloud extension is vulnerable to reflected XSS by abusing the linkstyle attribute.

Reproduction steps:

  • Enable the WikiCategoryTagCloud extension
  • Enter the following code into Special:ExpandTemplates (or go to /wiki/Special:ExpandTemplates?wpInput=%7B%7B%23tag%3A%20tagcloud%0A%7C%0A%7Clinkstyle%3D%22%22onmouseenter%3D%22alert%28%27hi%20%3AD%27%29%22%22%0A%7D%7D%0A:
{{#tag: tagcloud
|
|linkstyle=""onmouseenter="alert('hi :D')""
}}
  • Hover over any of the links in the category cloud

image.png (192×411 px, 9 KB)

Cause:

$style (which is $linkstyle concatenated with additional inline css) is concatenated with HTML code: https://github.com/wikimedia/mediawiki-extensions-WikiCategoryTagCloud/blob/d6755701460e80f1787ef9df65cba7e3e862809f/includes/WikiCategoryTagCloud.php#L196

$linkstyle is checked using Sanitizer::checkCss (which only searches for a few css functions like url()), but nothing is escaped. While inserting tags is not possible since it seems that entering < or > into the {{#tag: parser function escapes these symbols, quotes can be used to add additional attributes like onmouseenter to the links, allowing JavaScript execution.
The author of this code might have assumed that quotes cannot inserted into parameters used in extension tags, since those are usually submitted via attributes, but this can be bypassed using the {{#tag: parser function, which allows quotes to be inserted.

$cloudStyle meanwhile cannot be abused for this since it is properly inserted into the HTML as an attribute using Html::openElement instead of string concatenation.

Further information

Tested on

  • MediaWiki 1.43.0 (d7861af)
  • MediaWiki 1.45.0-alpha (9a13b9e) (required adding imports for a few namespaced classes to get the extension to run without an error)

PHP: 8.3.14 (fpm-fcgi)
Browser: Firefox 138.0.3 (64-bit) on Fedora Linux 42
WikiCategoryTagCloud: 1.5 (d675570)

Event Timeline

ashley claimed this task.

Thank you for the detailed write-up, and, naturally, for the patch as well! ❤ I've applied it against gerrit master and merged the patch (rEWCTbee952ba5da2: [SECURITY] Prevent reflected XSS via the linkstyle attribute by using the Html…).

This ticket can now be closed and made public (but I lack the rights to do that myself, so...).

Thanks for the quick response and for merging my patch! Would it be possible (or necessary?) to backport this patch to other branches as well? Especially REL1_39, REL1_42, REL1_43 and REL1_44, since those versions of MediaWiki are still supported

Bawolff changed the visibility from "Custom Policy" to "Public (No Login Required)".May 18 2025, 6:52 PM
Bawolff changed the edit policy from "Custom Policy" to "All Users".

Change #1147157 had a related patch set uploaded (by Jack Phoenix; author: Jack Phoenix):

[mediawiki/extensions/WikiCategoryTagCloud@REL1_44] [SECURITY] Prevent reflected XSS via the linkstyle attribute by using the Html class to build the output

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

Change #1147158 had a related patch set uploaded (by Jack Phoenix; author: Jack Phoenix):

[mediawiki/extensions/WikiCategoryTagCloud@REL1_43] [SECURITY] Prevent reflected XSS via the linkstyle attribute by using the Html class to build the output

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

Change #1147159 had a related patch set uploaded (by Jack Phoenix; author: Jack Phoenix):

[mediawiki/extensions/WikiCategoryTagCloud@REL1_42] [SECURITY] Prevent reflected XSS via the linkstyle attribute by using the Html class to build the output

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

Change #1147160 had a related patch set uploaded (by Jack Phoenix; author: Jack Phoenix):

[mediawiki/extensions/WikiCategoryTagCloud@REL1_39] [SECURITY] Prevent reflected XSS via the linkstyle attribute by using the Html class to build the output

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

Change #1147160 merged by jenkins-bot:

[mediawiki/extensions/WikiCategoryTagCloud@REL1_39] [SECURITY] Prevent reflected XSS via the linkstyle attribute by using the Html class to build the output

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

Change #1147158 merged by jenkins-bot:

[mediawiki/extensions/WikiCategoryTagCloud@REL1_43] [SECURITY] Prevent reflected XSS via the linkstyle attribute by using the Html class to build the output

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

Change #1147157 merged by jenkins-bot:

[mediawiki/extensions/WikiCategoryTagCloud@REL1_44] [SECURITY] Prevent reflected XSS via the linkstyle attribute by using the Html class to build the output

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

Change #1147159 merged by jenkins-bot:

[mediawiki/extensions/WikiCategoryTagCloud@REL1_42] [SECURITY] Prevent reflected XSS via the linkstyle attribute by using the Html class to build the output

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

Thanks for the quick response and for merging my patch! Would it be possible (or necessary?) to backport this patch to other branches as well? Especially REL1_39, REL1_42, REL1_43 and REL1_44, since those versions of MediaWiki are still supported

As per above, I've done this now since you asked nicely and this is a simple and straightforward security patch, but in general, for the things I maintain I just don't bother with branches and non-LTS releases - maintaining many separate branches isn't worth the time and effort, given that the life cycle of non-LTS releases is fairly nonexistent. (I wasn't expecting you to know this, I'm just stating it for the record.)

Thanks! I too don't use these branches for the extension I maintain for similar reasons, but unfortunately on gerrit the branches always exist, and there are many people (including me) who just switch to the branch associated with the installed MW release for convenience since most extensions do it that way.

Additionally, the extension page stated that the compatibility policy was to use REL branches. I've changed it to master now so hopefully future users will use that branch and backports will no longer be necessary.

Additionally, the extension page stated that the compatibility policy was to use REL branches. I've changed it to master now so hopefully future users will use that branch and backports will no longer be necessary.

Generally it's a best practice to support MediaWiki versions within the current Wikimedia version lifecycle. It's what we try to do with MediaWiki, bundled extensions and skins and anything else that Wikimedia generally supports or runs in Wikimedia production. With random MediaWiki extensions like WikiCategoryTagCloud, the choice is always up to the maintainers or third-party users, but we'd still encourage proper version compatibility when feasible.

mmartorana renamed this task from Reflected XSS in WikiCategoryTagCloud to CVE-2025-53486: Reflected XSS in WikiCategoryTagCloud.Jul 8 2025, 5:41 PM