Page MenuHomePhabricator

CVE-2021-41798: XSS vulnerability in Special:Search
Closed, ResolvedPublicSecurity

Description

Steps to reproduce
  1. Create some article Test.
  2. Set MediaWiki:June to <img src=x onerror=alert(1)> (the month of the article creations needs to be choosen here).
  3. Go to Special:Search and search for Test, so that the newly created article shows up.
  4. Enjoy your alert box.

xss.png (755×1 px, 99 KB)

This is possible, because the date value is not being escaped.

$date = $this->specialPage->getLanguage()->userTimeAndDate(
	$result->getTimestamp(),
	$this->specialPage->getUser()
);

Event Timeline

proposed patch

sbassett added a project: SecTeam-Processed.
sbassett added subscribers: Mstyles, Reedy, sbassett.

Tagging @EBernhardson / Discovery-Search for a quick opinion on this security patch. We'd like to deploy this security patch to production but wanted to confirm with someone on the Search Team that the patch seemed sane and there weren't any obvious double-escaping issues or potential issues with hook reuse. Thanks.

Tagging @EBernhardson / Discovery-Search for a quick opinion on this security patch. We'd like to deploy this security patch to production but wanted to confirm with someone on the Search Team that the patch seemed sane and there weren't any obvious double-escaping issues or potential issues with hook reuse. Thanks.

+1, Changes looks appropriate to me. It doesn't look like this should result in any double escaping in core code.The hook is documented as having the passed date already HTML encoded, so at least in theory that should be expected by consumers and not double encoded there.

Reedy renamed this task from XSS vulnerability in Special:Search to CVE-2021-PENDING: XSS vulnerability in Special:Search.Sep 29 2021, 4:06 PM
Reedy renamed this task from CVE-2021-PENDING: XSS vulnerability in Special:Search to CVE-2021-41798: XSS vulnerability in Special:Search.Sep 29 2021, 8:44 PM

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/342282 moved some stuff around, thus the patch above is not going to cleanly apply to REL1_31. So here is the patch for REL1_31.

The original patch applied fine with a git am -3 :)

The original patch applied fine with a git am -3 :)

I should have tried that. Forget my comment then :)

Change 725055 had a related patch set uploaded (by Reedy; author: Zabe):

[mediawiki/core@REL1_31] SECURITY: Pass escaped HTML to FullSearchResultWidget::buildMeta

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

Change 725055 merged by jenkins-bot:

[mediawiki/core@REL1_31] SECURITY: Pass escaped HTML to FullSearchResultWidget::buildMeta

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

Change 725061 had a related patch set uploaded (by Reedy; author: Zabe):

[mediawiki/core@REL1_35] SECURITY: Pass escaped HTML to FullSearchResultWidget::buildMeta

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

Change 725061 merged by jenkins-bot:

[mediawiki/core@REL1_35] SECURITY: Pass escaped HTML to FullSearchResultWidget::buildMeta

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

Change 725066 had a related patch set uploaded (by Reedy; author: Zabe):

[mediawiki/core@REL1_36] SECURITY: Pass escaped HTML to FullSearchResultWidget::buildMeta

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

Change 725071 had a related patch set uploaded (by Reedy; author: Zabe):

[mediawiki/core@REL1_37] SECURITY: Pass escaped HTML to FullSearchResultWidget::buildMeta

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

Change 725074 had a related patch set uploaded (by Reedy; author: Zabe):

[mediawiki/core@master] SECURITY: Pass escaped HTML to FullSearchResultWidget::buildMeta

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

Change 725066 merged by jenkins-bot:

[mediawiki/core@REL1_36] SECURITY: Pass escaped HTML to FullSearchResultWidget::buildMeta

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

Reedy changed the visibility from "Custom Policy" to "Public (No Login Required)".Sep 30 2021, 6:24 PM
Reedy changed the edit policy from "Custom Policy" to "All Users".

Change 725071 merged by jenkins-bot:

[mediawiki/core@REL1_37] SECURITY: Pass escaped HTML to FullSearchResultWidget::buildMeta

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

Change 725074 merged by jenkins-bot:

[mediawiki/core@master] SECURITY: Pass escaped HTML to FullSearchResultWidget::buildMeta

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