prototype-pollution
它能做什么
这项技能介绍原型污染,这是 JavaScript 和 Node.js 中的一种漏洞,经过构造的键会改动所有对象都继承的基础对象。适合检查自己有权测试的代码的开发人员和审查人员。
适用场景
- ✓当开发人员要求智能体检查 Node.js 应用是否把不可信的 JSON 或查询数据合并进对象时。
- ✓当智能体审查项目依赖中存在风险版本的合并或克隆库时。
- ✓当团队需要确认某项发现确实产生了实际影响,而不仅仅是对象被改动时。
技能链接
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/prototype-pollution/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我检查我们的 Node.js 应用,看看用户提供的 JSON 能否改动其他所有对象共用的基础对象?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体查找深度合并和克隆调用,把不可信输入追踪到这些调用中,并将依赖版本与已知的风险版本进行比对。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Prototype Pollution Playbook
Prototype pollution is the JavaScript equivalent of a universal gadget:
plant a property on Object.prototype and it appears on every object in
the runtime. Worthless in isolation, deadly in chain (__proto__.isAdmin = true → auth bypass; __proto__.shell = "/bin/bash" → RCE via spawn).
1. Sinks — the libraries that still introduce sinks
Keep a running list per engagement. These continue to ship sinks in 2026:
- Deep-merge:
lodash.merge,deepmerge(pre-fix),merge-deep,deepExtend,hoek.merge,mixme - Deep-clone:
lodash.defaultsDeep,lodash.zipObjectDeep,set-value(pre-3.0.3) - URL-to-obj:
qs,express-fileupload,jquery.extend(true, ...) - Config loaders:
node-configrecursive merge,dotenv-extended,rc - Template engines: Handlebars helpers fed from untrusted ctx
# Every JS/TS project: sweep known-bad versions
jq '.dependencies,.devDependencies | to_entries[] | select(.key | test("merge|lodash|set-value|dot-object|dot-prop|node-pg"))' /workspace/src/package.json
npm ls lodash set-value dot-prop 2>/dev/null | grep -E '[0-9]'
2. Sources
Any user input deserialized into a nested object:
- JSON body parsers (
body-parser,express.json) - Query string parsers (
qswith default config parsesa[b][__proto__][c]=1) - YAML uploads
- Form-data / multipart
3. Audit workflow
- Find every deep merge call site.
- Trace each one backwards — is the right-hand object user-controlled?
- If yes: check the merge function's prototype-pollution fix version.
- Even if the merge is fixed, check whether a copy (lodash.set, dot-path-value, jsonpath.set) creates a pollution path.
4. Exploitation gadgets
Poisoning Object.prototype doesn't do anything by itself — you need
a gadget that reads a property that didn't exist before.
Classic gadgets:
child_process.spawn(cmd, args, opts)— opts has ashelloption. Poison__proto__.shell = "/bin/bash"then any subsequent spawn call executes through bash and interprets args as shell strings.- Express middleware — most middlewares check
options.someFlagwithif (opts.someFlag). Poisoning that flag flips security defaults. - Templating — Handlebars and EJS read
helpersandpartialsfrom the context object; pollution adds helpers that execute code. lodash.template— if the template source is built from_.template(tpl, ctx)you can inject via pollutedescape/evaluatekeys.mongoose— pollutingSchema.Typescauses subsequent schema definitions to use attacker-controlled types.
5. PoC template
# Classic lodash.merge RCE via child_process.spawn
curl -X POST https://target.com/api/settings \
-H 'Content-Type: application/json' \
-d '{"__proto__": {"shell": "/bin/bash", "env": {"PATH": "/tmp:/usr/bin"}}}'
# Second request triggers the gadget
curl https://target.com/api/render-pdf
# → any subsequent child_process.spawn call now runs through /bin/bash
6. Success signals for validate_finding
- Server error with stack trace referencing
Object.prototype - Output of injected command reflected in next response
- Admin-only endpoint now returns 200 after poisoning
__proto__.isAdmin
Negative control: same payload with proto (no leading underscores) —
should have no effect. If it does, the endpoint is treating that key
specially and the finding is unrelated.
7. Default CVSS
| Variant | Vector | Score |
|---|---|---|
| DoS (crash Node process) | AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | 7.5 |
Auth bypass via isAdmin pollution |
AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N | 9.1 |
| RCE via spawn gadget | AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H | 10.0 |
8. Chain promotion
Prototype pollution is almost always the first hop of a chain. After
validation, add an enables edge from the pollution vuln to:
- the spawn / template gadget vuln (RCE chain)
- the auth check vuln (privilege escalation chain)
- the SSRF vuln if the downstream request lib has an options pollution surface
Chain weight 0.4 — pollution is cheap once the merge sink is known.
常见问题
什么是原型污染?
就是经过构造的键为基础对象添加属性,于是这一改动会出现在许多其他对象中。
哪些输入有风险?
该技能列出 JSON 请求体、查询字符串、YAML 上传文件和表单数据等常见来源。
该技能提到了哪些库?
它列出了几个深度合并和克隆库,并指出智能体应检查已安装的版本。
详情
作者的原始描述
Hunt JavaScript prototype pollution (CWE-1321) — the 2023-2026 meta-vulnerability that chains into RCE, auth bypass, and SSRF on most Node.js stacks.
热度
- GitHub 星标
- 6.5k
- 排名
- #13967
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/1
评论
- …