Page MenuHomePhabricator

XSS in SearchHighlighter::highlightText() [requires non-default config]
Closed, ResolvedPublic

Description

CVE-2017-0365

SearchHighlighter::removeWiki() uses a regex to remove html from snippets. The regex - /<\/?[^>]+>/ assumes that html is well-formed. As a result when using SearchHighlighter::highlightText() as the highlighting method, this can result in an XSS. (Note it is not the default highlighting method. Additionally it is not in use on Wikimedia)

Steps to reproduce:

  1. Use default mysql search (i.e. Not cirrus)
  2. Set $wgAdvancedSearchHighlighting
  3. Create a page with the content <img onerror="alert(1)" src=x Cat Dog
  4. Search for Cat Dog
  5. This should cause the <img> tag in the search results, resulting in a pop-up box

Event Timeline

dpatrick triaged this task as High priority.
dpatrick added a project: Vuln-XSS.

Discovery has not been prioritising reviewing this because it does not affect the Wikimedia cluster. @EBernhardson said that @Bawolff should feel free to merge this patch if he thinks it fixes it. Does that satisfy those involved? :-)

We don't think there's any outstanding work for the Search Team here, so I'm removing Discovery-Search.

Discovery has not been prioritising reviewing this because it does not affect the Wikimedia cluster. @EBernhardson said that @Bawolff should feel free to merge this patch if he thinks it fixes it. Does that satisfy those involved? :-)

Sorry, I didn't see your comment. To clarify, this is primarily waiting on us having our next security release (Since this isn't used by Wikimedia, no need to really deploy to cluster)

Bawolff added a subscriber: MarkAHershberger.

Sorry, I didn't see your comment. To clarify, this is primarily waiting on us having our next security release (Since this isn't used by Wikimedia, no need to really deploy to cluster)

No problem. Understood. Thanks!

Rebased /backported versions of patch:




Umm, the previous 1.23 patch was the wrong file. Fixed version below:

Reedy subscribed.

Closing for ease of tracking progress. Patches attached to parent bug, due for next release

Reedy changed the visibility from "Custom Policy" to "Public (No Login Required)".Apr 6 2017, 8:57 PM

Change 346840 merged by jenkins-bot:
[mediawiki/core@master] SECURITY: XSS in search if $wgAdvancedSearchHighlighting = true;

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

Change 346859 merged by jenkins-bot:
[mediawiki/core@REL1_28] SECURITY: XSS in search if $wgAdvancedSearchHighlighting = true;

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

Change 346849 merged by jenkins-bot:
[mediawiki/core@REL1_27] SECURITY: XSS in search if $wgAdvancedSearchHighlighting = true;

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