
إثبات مفهوم تقني وتحليل متعمق لـ CVE-2025-55182، وهي ثغرة RCE حرجة في بروتوكول Flight الخاص بـ React عبر اجتياز المسار، وحقن أجزاء مزيفة، وإساءة استخدام معالج $B.
NOTE: Written by AI/Claude
https://github.com/ejpir/CVE-2025-55182-bypass
CVE-2025-55182 هي ثغرة RCE حرجة في بروتوكول Flight الخاص بـ React. سلسلة الهجوم تجمع بين اجتياز المسار + حقن كتلة مزيفة + إساءة استخدام معالج $B لتنفيذ Function(attacker_code).
شكر كبير لـ maple3142 على سلسلة الاستغلال العاملة!
يستخدم الاستغلال ثلاثة حقول نموذج لبناء حمولة ضارة:
then مرجع ذاتي (الحقل 1 $@0 → الحقل 0)_response مزيفًا حيث يكون _formData.get مضبوطًا على $1:constructor:constructor$B الذي يستدعي response._formData.get(response._prefix + id)_formData.get → Function، لينفذ Function(code)┌─────────────────────────────────────────────────────────────────────┐ │ 1. Attacker sends multipart form with fake chunk object │ │ → decodeReply() parses form fields 0, 1, 2 │ │ → Object has: then, status, value, _response │ └─────────────────────────────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────────┐ │ 2. Self-reference makes object thenable with real function │ │ → then: "$1:proto:then" → Chunk.prototype.then │ │ → Chunk.prototype.then(this) calls initializeModelChunk(this) │ │ → Uses this._response (attacker's fake _response) │ └─────────────────────────────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────────┐ │ 3. parseModelString() handles "$B1337" reference │ │ → case "B": return response._formData.get(response._prefix+id) │ │ → Calls _formData.get with attacker's _prefix + "1337" │ └─────────────────────────────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────────┐ │ 4. getOutlinedModel() resolves _formData.get (lazy evaluation): │ │ → "$1:constructor:constructor" traverses prototype chain │ │ → Returns Function constructor │ │ → Function(code + "1337") → RCE │ └─────────────────────────────────────────────────────────────────────┘
### Key Components
| Component | الغرض |
|-----------|---------|
| `then: "$1:__proto__:then"` | ثمينة ذاتية الإشارة؛ القطعة 1 (`$@0`) تشير إلى القطعة 0 |
| `status: "resolved_model"` | يجعل الكائن يبدو كقطعة React صالحة |
| `reason: -1` | يضبط rootReference على undefined (يتجنب تعارضات المرجع) |
| `value: '{"then":"$B1337"}'` | حمولة متداخلة تؤدي إلى تشغيل معالج `$B` |
| `_response._prefix` | يحتوي على نص كود RCE |
| `_response._chunks: "$Q2"` | خريطة فارغة لمنع الأعطال أثناء معالجة القطعة |
| `_response._formData.get` | يشير إلى `Function` عبر `$1:constructor:constructor` |
### Component Deep Dive
#### بنية حقل النموذج
يستخدم الاستغلال ثلاثة حقول نموذج بمراجع دائرية:```
Field 0: {"then":"$1:__proto__:then", "status":"resolved_model", ...}
Field 1: "$@0" ← references back to field 0
Field 2: [] ← empty array for _chunks Map
then)إن then: "$1:__proto__:then" ينشئ مرجعًا ذاتيًا يتحول إلى دالة حقيقية:```
$1:proto:then
↓
$1 → chunk 1 → "$@0" → getChunk(0) → Chunk object
↓
Chunk.proto.then → Chunk.prototype.then (actual function!)
**لماذا هذا بالغ الأهمية:**
1. تشير `then` إلى `Chunk.prototype.then` - وهي دالة قابلة للاستدعاء حقيقية
2. وهذا يجعل الكائن المزيف thenable صالحًا
3. عندما يتم الانتظار، تستدعي JS `obj.then(resolve, reject)`
4. يتم تنفيذ `Chunk.prototype.then` مع الكائن المزيف كـ `this`:```javascript
Chunk.prototype.then = function (resolve, reject) {
switch (this.status) { // this.status = "resolved_model" ✓
case "resolved_model":
initializeModelChunk(this); // fake object passed!
initializeModelChunk(this) يستخدم this._response - الـ _response المزيف للمهاجم:```javascript
value = reviveModel(
chunk._response, // ← attacker's fake _response!
...
);**بدون المرجع الذاتي**، لن يتم استخدام `_response` المزيف أبدًا. المرجع الذاتي يجعل `Chunk.prototype.then` يعالج كائن المهاجم كـ Chunk حقيقي.
#### مشغل Thenable ذو مرحلتين (`value`)
حقل `value` يحتوي على سلسلة JSON متداخلة مع thenable آخر:```json
{"then":"$B1337"}
المرحلة 1: then المرجعي للكائن الخارجي يؤدي إلى معالجة القطعة
المرحلة 2: عندما يحل React النموذج، فإنه يوزع value ويصادف thenable آخر مع then: "$B1337". البادئة $B تؤدي إلى معالج:```javascript
case "B":
return response._formData.get(response._prefix + obj); // obj = "1337"
`_formData.get` هو `"$1:constructor:constructor"` → `getOutlinedModel()` يتحول إلى `Function`.
يصبح هذا: `Function(code + "1337")` → كود JS صحيح لأن `1337` مجرد تعبير زائد.
#### الحشو الدفاعي (`_chunks`)
الاستجابة المزيفة `_response` تحتاج إلى خاصية `_chunks` صالحة لمنع الانهيار:```
Form field "2": [] ← empty array
_chunks: "$Q2" ← $Q = Map type, creates new Map([])
قد يصل الكود الداخلي لـ React إلى response._chunks.get() أو response._chunks.has() أثناء المعالجة. الـ Map الفارغ يلبي هذه الاستدعاءات دون أخطاء، مما يسمح للتنفيذ بالوصول إلى المعالج الضعيف $B.
| المسار | الوظيفة | الغرض في الاستغلال |
|---|---|---|
| اجتياز المسار | getOutlinedModel() | يحل $1:constructor:constructor → Function |
حقن _response مزيف | initializeModelChunk() | يستخدم chunk._response الخاص بالمهاجم |
معالج $B | parseModelString() | يستدعي _formData.get(_prefix + id) → تنفيذ التعليمات البرمجية عن بُعد (RCE) |
decodeReply() هي نقطة الدخول، وهي ليست ضعيفة بذاتها.
اجتياز المسار (getOutlinedModel()):```javascript
for (key = 1; key < reference.length; key++)
parentObject = parentObject[reference[key]]; // No validation!
**استخدام الاستجابة المزيفة** (`initializeModelChunk()`):```javascript
value = reviveModel(
chunk._response, // Uses chunk._response directly!
{ "": rawModel },
...
);
$B Handler RCE (parseModelString()):```javascript
case "B":
return response._formData.get(response._prefix + obj); // RCE!
---
## الإصلاح (19.2.1)
يتضمن التصحيح عدة إصلاحات:
1. **`RESPONSE_SYMBOL` في `initializeModelChunk()`** - إصلاح حاسم ```javascript
// BEFORE: chunk._response (attacker can set via JSON)
value = reviveModel(chunk._response, ...);
// AFTER: Symbol lookup (cannot be forged via JSON)
var response = chunk.reason[RESPONSE_SYMBOL];
value = reviveModel(response, ...);
hasOwnProperty check in getOutlinedModel() - يمنع اجتياز النموذج الأولي ```javascript
hasOwnProperty.call(value, name) && (value = value[name]);
__proto__ التعامل مع في reviveModel() - يمنع تلوث النموذج الأولي ```javascript
void 0 !== parentObj || "proto" === i
? (value[i] = parentObj)
: delete value[i];
initializeModelChunk() - التحقق من صحة المستمعين ```javascript
"function" === typeof listener
? listener(value)
: fulfillReference(response, listener, value);
| القدرة | الحالة | ملاحظات |
|---|---|---|
| اجتياز سلسلة النموذج الأولي | ✓ مؤكد | عبر $1:constructor:constructor |
| الوصول إلى مُنشئ الدالة | ✓ مؤكد | لا حاجة إلى البيان |
| تنفيذ الأوامر عن بُعد (RCE) | ✓ مؤكد | عبر القطعة الزائفة + معالج $B |