Page MenuHomePhabricator

CVE-2026-22710: Stored XSS through autocomment system messages in Wikibase
Closed, ResolvedPublicSecurity

Description

Wikibase inserts parsed system messages into autocomments by using the FormatAutocomments hook. This allows for XSS, because it is not safe to pass parsed HTML to the comment parser.
Fortunately, this is no longer exploitable by unprivileged users since the message arguments were wikitext-escaped in 2017 due to T182800: Username beginning with asterisk renders as list in “restore”/“undo” edit summaries of Wikibase items (whether it was actually exploitable before that depends on whether users were able to insert angle brackets into the arguments, which in turn depends on what data was actually used in the parameters).

Reproduction steps

  1. Enable WikibaseRepository (see the Additional information section regarding WikibaseClient)
  2. Edit MediaWiki:Wikibase-entity-summary-wbsetdescription-set and set its contents to <pre tabindex="0" data-xss="[[#/autofocus/onfocus=alert(1);//">]]</pre>
  3. Edit the description of an item
  4. Go to the revision history of the item

image.png (187×490 px, 9 KB)

The payload will also be executed in other places that render edit summaries, like Special:RecentChanges.

Explanation

By including wiki link syntax in the attribute of an element that is passed to CommentParser::doWikiLinks, it's possible to insert arbitrary HTML attributes in the element, because the CommentParser will insert the link element into the attribute (see also T355538 and T406664).
Normal HTML elements created by the Parser will escape characters like [ to prevent XSS through link replacement. However, <pre> creates the element using Html::element and inserts it using a strip marker, which will be unstripped in internalParseHalfParsed, which means that we can insert square brackets into attributes.
The parsed message is appended to the autocomment here. After this, the CommentParser will replace the link syntax with the HTML link, thereby creating unsafe HTML which executes the payload.

As far as I can see, all messages that are used here (presumably all 59 starting with wikibase-entity-summary-) can be abused for this.

Additional information

  • MediaWiki: 1.46.0-alpha
  • WikibaseRepository: 686238a

This is not fixed by the patch for T406664 because text inserted via the hook bypasses the mitigation.

This is also exploitable with WikibaseClient, which also handles custom autocomments using the hook, and doesn't even check for the namespace while doing so (which means that the user can insert edit summaries that match the regex the AutoCommentFormatter requires). However, it isn't easy to perform XSS this way because it requires $wikiId to be set, which will cause the CommentParser to only create external links (apart from file links, which weren't exploitable either when I tried this). If $wgExternalInterwikiFragmentMode is set to legacy (the default value), any external links generated by the CommentParser will url-encode = in the path and the fragment, which means only boolean attributes can be used. With $wgExternalInterwikiFragmentMode = 'html5'; however, this vulnerability is likely also exploitable with WikibaseClient.

Event Timeline

The easiest solution here is to escape the message rather than parse it:


However, this assumes that the messages don't need to be parsed. As far as I can see, this is true for the default English translations, but there is probably some reason this was implemented this way...

Alternatively, the wikilink regex in the comment parser could be adjusted to skip text inside elements (example in the legacy parser), which would also prevent any other XSSs through this hook.

SomeRandomDeveloper renamed this task from Stored XSS through edit summary system messages in Wikibase to Stored XSS through autocomment system messages in Wikibase.Nov 10 2025, 3:40 PM

As far as I can see, all messages that are used here (presumably all 59 starting with wikibase-entity-summary-) can be abused for this.

Note that other messages can also be used in the edit summary – wikibase-item-summary-, wikibase-property-summary-, wikibase-lexeme-summary- (WikibaseLexeme / Wikidata Lexicographical data), wikibase-mediainfo-summary- (WikibaseMediaInfo / SDC General). So ideally we would also check those (including translations) if they’re okay with swapping ->parse() for ->escaped().

As far as I can see, all messages that are used here (presumably all 59 starting with wikibase-entity-summary-) can be abused for this.

Note that other messages can also be used in the edit summary – wikibase-item-summary-, wikibase-property-summary-, wikibase-lexeme-summary- (WikibaseLexeme / Wikidata Lexicographical data), wikibase-mediainfo-summary- (WikibaseMediaInfo / SDC General). So ideally we would also check those (including translations) if they’re okay with swapping ->parse() for ->escaped().

Thanks. Taking a look at the English translations, the only messages using wikitext are wikibase-entity-summary-restore and wikibase-entity-summary-undo. But since they're only using links, if the message is escaped, the CommentParser will still parse the links:

image.png (72×273 px, 7 KB)

The resulting HTML seems to remain identical.

(Just to set expectations here, I’ll try to look at this tomorrow but can’t guarantee it; I certainly won’t have time to review / try out the patch today. My impression is that this isn’t super urgent as the impact is limited to sysops.)

(Just to set expectations here, I’ll try to look at this tomorrow but can’t guarantee it; I certainly won’t have time to review / try out the patch today. My impression is that this isn’t super urgent as the impact is limited to sysops.)

I think this can be considered lower severity than most other i18n XSSs reported in the past, which were either discoverable using x-xss, or very obvious to find in the code. I only found this because I was looking for vulnerabilities similar to T406664, but I don't think this is something you can realistically stumble upon by accident.

sbassett added a project: SecTeam-Processed.
sbassett subscribed.

I think this can be considered lower severity than most other i18n XSSs reported in the past, which were either discoverable using x-xss, or very obvious to find in the code. I only found this because I was looking for vulnerabilities similar to T406664, but I don't think this is something you can realistically stumble upon by accident.

+1, not an emergency IMO, but something we'd want to get deployed in a week or so, just so it doesn't become stale.

This will affect a handful of alias-related messages in Ido (io):

Adjuntita [en] pseudonimo (''alias''): Doug Adams

Previously, it effectively looks like this instead:

Adjuntita [en] pseudonimo (alias): Doug Adams

(MediaWiki doesn’t include styles to render <i> inside an edit summary upright again, so it’s just italic-inside-italic, i.e. no visual distinction.) I think it’s okay to accept this regression for now and edit the translations on translatewiki.net later.

I haven’t found any other incompatible wikitext in any of the message translations:

grep '"wikibase-[^"]*-summary' extensions/Wikibase/lib/i18n/*.json extensions/WikibaseLexeme/i18n/*.json extensions/WikibaseMediaInfo/i18n/*.json | grep -vF /qqq.json: | less

{{PLURAL:}} still works, {{#commaseparatedlist:}} still works, {{WBREPONAME}} (in two Hebrew messages) still works. There are no other brace constructs (search for \{\{(?!PLURAL|#commaseparatedlist|WBREPONAME) in less), nor was any other wikitext I looked for present (though I’m sure I missed some obscure corner cases – there’s a lot of wikitext syntax to go around).

CR+1, patch LGTM. I’ll try to find some time to deploy it later today, though I’m not sure when it will be.

F70079448 applies on REL1_45.
Rebased patch for REL1_44 and REL1_43 (also applies on REL1_39 in case that's still supported in the next supplemental release):

Haven’t confirmed that it applies to the different branches but CR+1 for the patch contents – should be okay to try applying to the branches when the time comes.

Haven’t confirmed that it applies to the different branches but CR+1 for the patch contents – should be okay to try applying to the branches when the time comes.

Patch no longer applied, but I have uploaded the change to gerrit, please review @SomeRandomDeveloper @Lucas_Werkmeister_WMDE

Not sure why gerritbot didn't pick it up, but it's https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/1224221

hashar subscribed.

I am removing the GerritBot project tag since this task does not affect Gerrit.

Haven’t confirmed that it applies to the different branches but CR+1 for the patch contents – should be okay to try applying to the branches when the time comes.

Patch no longer applied, but I have uploaded the change to gerrit, please review @SomeRandomDeveloper @Lucas_Werkmeister_WMDE

Not sure why gerritbot didn't pick it up, but it's https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/1224221

That patch was intended for REL1_44 (and F70079448 for master), but the version on gerrit linked above looks fine to me

Change #1224221 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] SECURITY: Escape system messages in autocomments

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

Change #1224662 had a related patch set uploaded (by SomeRandomDeveloper; author: Mstyles):

[mediawiki/extensions/Wikibase@REL1_45] SECURITY: Escape system messages in autocomments

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

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

[mediawiki/extensions/Wikibase@REL1_44] SECURITY: Escape system messages in autocomments

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

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

[mediawiki/extensions/Wikibase@REL1_43] SECURITY: Escape system messages in autocomments

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

Change #1224662 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@REL1_45] SECURITY: Escape system messages in autocomments

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

Change #1224665 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@REL1_43] SECURITY: Escape system messages in autocomments

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

@SomeRandomDeveloper thank you and I see I used the wrong tag for gerrit, apologies!

Change #1224664 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@REL1_44] SECURITY: Escape system messages in autocomments

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

Mstyles renamed this task from Stored XSS through autocomment system messages in Wikibase to CVE-2026-22710: Stored XSS through autocomment system messages in Wikibase.Jan 8 2026, 11:51 PM
Mstyles changed the visibility from "Custom Policy" to "Public (No Login Required)".
Mstyles changed the edit policy from "Custom Policy" to "All Users".
SomeRandomDeveloper claimed this task.

I assume this is resolved now.