George0Papasotiriou/CVE-2026-3030-Prototype-Pollution-in-JSON-Merge-Patch

GitHub: George0Papasotiriou/CVE-2026-3030-Prototype-Pollution-in-JSON-Merge-Patch

该项目复现了 Node.js 中因不安全的深度合并函数导致的原型污染漏洞(CVE-2026-3030),并提供了可运行的脆弱服务及利用脚本。

Stars: 0 | Forks: 0

## CVE-2026-3030 – JSON Merge Patch 中的原型污染 ### **程序代码 (Node.js)** ``` // server.js - Vulnerable REST API with deep merge const express = require('express'); const app = express(); app.use(express.json()); let config = { role: 'user', settings: {} }; // Insecure deep merge function (pollutable via __proto__) function deepMerge(target, source) { for (const key in source) { if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) { if (!target[key]) target[key] = {}; deepMerge(target[key], source[key]); } else { target[key] = source[key]; } } return target; } app.patch('/config', (req, res) => { deepMerge(config, req.body); res.json(config); }); app.get('/admin', (req, res) => { // Check admin via a property that could be polluted if (config.role === 'admin' || config.isAdmin) { res.send('Welcome Admin!'); } else { res.status(403).send('Forbidden'); } }); app.listen(3000, () => console.log('Server on :3000')); ``` # CVE-2026-3030 – 通过 JSON Merge Patch 进行原型污染 ![严重性:高](https://img.shields.io/badge/severity-high-orange) ## 概述 一个 Node.js API 使用了存在漏洞的深度合并函数来应用 JSON 补丁。通过发送 `__proto__` 作为键,攻击者可以污染全局对象原型,添加或覆盖如 `isAdmin` 等属性,从而导致权限提升。 ## 漏洞详情 - **类型:** 原型污染 - **影响:** 权限提升、拒绝服务,有时会导致 RCE。 - **根本原因:** `deepMerge` 函数在复制键时未检查 `__proto__` 或 `constructor`,从而允许注入到 `Object.prototype` 中。 ## 漏洞利用演示 1. 启动服务器: npm install express node server.js 2. 运行漏洞利用: python exploit_prototype_pollution.py
标签:GNU通用公共许可证, Maven, MITM代理, Node.js, Web报告查看器, 协议分析, 原型链污染, 安全漏洞, 权限提升, 漏洞验证, 自定义脚本, 逆向工具