Page MenuHomePhabricator

CVE-2023-29135: CheckUser 'get users' form vulnerable to HTML injection through usernames
Closed, ResolvedPublicSecurity

Description

Steps to replicate the issue (include links if applicable):

Original steps
In CU get users tab I selected the checkboxes for accounts named Aée"a"zaEFZgrtsgewr, Aée"a"zaEFZ and Aée"a"za among others, entered a reason for blocking them and hit the block button.

Steps for the larger issue behind this

  • Register an account with the username Test" onclick="alert('test');"
  • Log into an account that can access CheckUser
  • Run 'Get IP Addresses' on the account created in step 1
  • Click on an IP shown in the results
  • Run 'Get users' on that IP
  • Click the checkbox for the user created in step 1

What happens?:

Original
The three named accounts were not blocked, the other accounts without accentuated letters were successfully blocked.

For the wider issue
An alert box is displayed showing that HTML injection can occur, including JS injection.

What should have happened instead?:

Original
All selected accounts should've been blocked.

For the wider issue
The username should have been properly escaped.

Software version (skip for WMF-hosted wikis like Wikipedia):

WMF Production. Meta-Wiki.

Also on a localhost testing wiki

Other information (browser name/version, screenshots, etc.):

I've manually blocked the accounts myself.

Selecting them to use Special:MultiLock breaks too. I suspect this is the quotes " in their usernames.

Event Timeline

MarcoAurelio renamed this task from CheckUser did not block a selected account to CheckUser did not block some selected accounts.Mar 4 2023, 11:07 AM
MarcoAurelio updated the task description. (Show Details)
Dreamy_Jazz triaged this task as High priority.EditedMar 15 2023, 7:23 PM
Dreamy_Jazz subscribed.

Found the cause. The mustache template did not HTML escape the username which means " characters causes the defined username to be ended early. This means the CheckUser form tried to block User:Aée.

Triaging as High due to the risk of unintentional blocking of unrelated accounts.

This should not allow any injection attacks because the ">" character is not defined as an allowed character to be in a username. This means that ending the input tag to start a new one (which injects HTML) would not be possible. However, this fix should be backported to release 1.39.

Dreamy_Jazz raised the priority of this task from High to Needs Triage.Mar 15 2023, 7:33 PM
Dreamy_Jazz set Security to Software security bug.
Dreamy_Jazz changed the visibility from "Public (No Login Required)" to "Custom Policy".
Dreamy_Jazz changed the subtype of this task from "Bug Report" to "Security Issue".

Actually I think this is an issue because it could allow the insertion of other attributes to the input tag.

Example HTML injection with the onclick handler:

image.png (807×1 px, 160 KB)

Dreamy_Jazz renamed this task from CheckUser did not block some selected accounts to CheckUser 'get users' form vulnerable to HTML injection.Mar 15 2023, 7:42 PM
Dreamy_Jazz triaged this task as High priority.
Dreamy_Jazz renamed this task from CheckUser 'get users' form vulnerable to HTML injection to CheckUser 'get users' form vulnerable to HTML injection through usernames.Mar 15 2023, 7:47 PM
Dreamy_Jazz updated the task description. (Show Details)
Mstyles renamed this task from CheckUser 'get users' form vulnerable to HTML injection through usernames to CVE-2023-29135: CheckUser 'get users' form vulnerable to HTML injection through usernames.Apr 4 2023, 4:19 AM

Change 904920 had a related patch set uploaded (by Mstyles; author: Dreamy Jazz):

[mediawiki/extensions/CheckUser@master] Escape HTML in the user text for the checkbox in get users

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

Change 905267 had a related patch set uploaded (by Mstyles; author: Dreamy Jazz):

[mediawiki/extensions/CheckUser@REL1_39] Escape HTML in the user text for the checkbox in get users

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

Change 905267 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@REL1_39] SECURITY: Escape HTML in the user text for the checkbox in get users

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

Change 904920 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] SECURITY: Escape HTML in the user text for the checkbox in get users

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

Mstyles claimed this task.

I've also backported this to 1.40.

mmartorana changed the visibility from "Custom Policy" to "Public (No Login Required)".Apr 4 2023, 7:08 PM