跳到正文
Skillpedia
安全6.5k · #13967

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/prototype-pollution/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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-config recursive 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 (qs with default config parses a[b][__proto__][c]=1)
  • YAML uploads
  • Form-data / multipart

3. Audit workflow

  1. Find every deep merge call site.
  2. Trace each one backwards — is the right-hand object user-controlled?
  3. If yes: check the merge function's prototype-pollution fix version.
  4. 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 a shell option. 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.someFlag with if (opts.someFlag). Poisoning that flag flips security defaults.
  • Templating — Handlebars and EJS read helpers and partials from 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 polluted escape/evaluate keys.
  • mongoose — polluting Schema.Types causes 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.

repo: BitterSecurity/Decepticon

热度

GitHub 星标
6.5k
排名
#13967
许可证
Apache-2.0
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能