Stored XSS leads to privilege escalation in MediaWiki v1.40.0
7.3
High
Discovered by

Offensive Team, Fluid Attacks
Summary
Full name
Stored XSS leads to privilege escalation in MediaWiki v1.40.0
Code name
State
Private
Release date
Oct 11, 2023
Affected product
product: MediaWiki
Affected version(s)
Version 1.40.0
Vulnerability name
Stored cross-site scripting
Vulnerability type
Remotely exploitable
Yes
CVSS v3.1 vector string
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N
CVSS v3.1 base score
7.3
Exploit available
Yes
CVE ID(s)
Description
Mediawiki v1.40.0 does not validate namespaces used in XML files. Therefore, if the instance administrator allows XML file uploads, a remote attacker with a low-privileged user account can use this exploit to become an administrator by sending a malicious link to the instance administrator.
Vulnerability
In Mediawiki v1.40.0, an authenticated remote attacker can escalate his privileges through a Stored XSS. Thanks to this, we can perform a CSRF on an administrative account to escalate the privileges of an arbitrary account.
The Stored XSS is caused by MediaWiki v1.40.0 not validating the namespaces used in XML files. Thanks to this we can bypass the script detection security controls.
Exploit failed
Here our exploit attempt fails, thanks to the script being detected correctly:

Exploit Success
Here the exploit worked, since we bypassed the script detection controls by using a namespace:

Exploit
To exploit the vulnerability we built an XML file that uses a namespace to bypass script detection protection. This script loads an external script which seeks to escalate the privileges of an account when the administrator accesses the malicious XML link through a CSRF.
exploit.xml
payload.js
Evidence of exploitation
Here is a step-by-step description of how to exploit this vulnerability. Basically what will be shown below is how a user with low privileges can increase his privileges by sending a malicious link to the instance administrator.
Our security policy
We have reserved the CVE-2023-3550 to refer to these issues from now on.
System Information
Version: MediaWiki 1.40.0
Operating System: MacOS
Mitigation
There is currently no patch available for this vulnerability.
References
Vendor page https://www.mediawiki.org/wiki/MediaWiki
Timeline
Vulnerability discovered
Jul 7, 2023
Vendor Confirmed Vuln.
Jul 11, 2023
Vendor contacted
Jul 7, 2023
Vendor replied
Jul 11, 2023
Public disclosure
Oct 11, 2023