Page MenuHomePhabricator

XSS in Special:Search
Closed, ResolvedPublicSecurity

Description

This bug was reported to security@ by Sheldon Menezes (samymenezes33@gmail.com)

Steps to reproduce:

  • write '><script>alert(document.domain)</script> in a search box
  • the response will evaluate the javascript

Event Timeline

Joe triaged this task as Unbreak Now! priority.Oct 14 2022, 9:33 AM

patch uploaded to deploy1002:~dcausse/T320785.patch

From 9869e7b749eb51bddee41cc713c69eacf47b3284 Mon Sep 17 00:00:00 2001
From: David Causse <dcausse@wikimedia.org>
Date: Fri, 14 Oct 2022 11:40:47 +0200
Subject: [PATCH] Fix XSS in DYM

Bug: T320785
Change-Id: Ib9e2da2291b9936f3f1646322c9a14acec37738c
---
 includes/search/searchwidgets/DidYouMeanWidget.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/includes/search/searchwidgets/DidYouMeanWidget.php b/includes/search/searchwidgets/DidYouMeanWidget.php
index 9dd4e1f6683..a3728902220 100644
--- a/includes/search/searchwidgets/DidYouMeanWidget.php
+++ b/includes/search/searchwidgets/DidYouMeanWidget.php
@@ -78,7 +78,8 @@ class DidYouMeanWidget {
 		$original = $term;
 
 		return $this->specialSearch->msg( 'search-rewritten' )
-			->rawParams( $rewritten, $original )
+			->rawParams( $rewritten )
+			->params( $original )
 			->escaped();
 	}
 
-- 
2.34.1

The above patch has been deployed to all wmf production wikis.
It is stored in /srv/patches/1.40.0-wmf.5/core/T320785.patch on deploy1002
The problem was introduced in 1.40.0-wmf.5 by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/824123.

@sbassett is it ok to push the patch through gerrit and make this task public? It is a recent regression and only master is affected and prod has been patched.

@sbassett is it ok to push the patch through gerrit and make this task public? It is a recent regression and only master is affected and prod has been patched.

Normally we'd hold something like this for the next security release (T318964), but since it should have only ever made it to 1.40, I think it's fine to get this merged so the patch can fall off next week (assuming it gets merged today or Monday).

Change 842818 had a related patch set uploaded (by Zabe; author: DCausse):

[mediawiki/core@master] SECURITY: Fix XSS in DYM

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

sbassett lowered the priority of this task from Unbreak Now! to High.Oct 14 2022, 2:30 PM
sbassett changed Author Affiliation from N/A to Other (Please specify in description).
sbassett changed the visibility from "Custom Policy" to "Public (No Login Required)".
sbassett changed the edit policy from "Custom Policy" to "All Users".
sbassett changed Risk Rating from N/A to High.
Zabe assigned this task to dcausse.

Change 842818 merged by jenkins-bot:

[mediawiki/core@master] SECURITY: Fix XSS in DYM

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

Running the train today for 1.40.0-wmf.6 shows the patch already got applied.

[ALREADY APPLIED] /srv/patches/1.40.0-wmf.6/core/01-T320785.patch

It got merged in master last week and made its way in 1.40.0-wmf.6. I have removed the patch from the /srv/patches repository.

Change 852935 had a related patch set uploaded (by SBassett; author: SBassett):

[wikimedia/security/landing-page@master] Add Sheldon Menezes to security hall of fame for reporting XSS in Special:Search

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

Change 852935 merged by jenkins-bot:

[wikimedia/security/landing-page@master] Add Sheldon Menezes to security hall of fame for reporting XSS in Special:Search

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

Change 854107 had a related patch set uploaded (by SBassett; author: SBassett):

[wikimedia/security/landing-page@master] Add Sheldon Menezes to security hall of fame (build step)

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

Change 854107 merged by jenkins-bot:

[wikimedia/security/landing-page@master] Add Sheldon Menezes to security hall of fame (build step)

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