> 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/business-logic/low-level-logic-flaw.md).

# Низкоуровневая логическая ошибка

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

### Ошибочное применение бизнес-правил

**Описание лабораторной работы**

В этой лабораторной работе есть \*\*логический дефект в процессе покупки\*\*. Из-за некорректного применения торговых правил можно манипулировать расчётом корзины, чтобы купить "Lightweight l33t leather jacket" по неожиданной цене.

Предоставленный идентификатор:

* **Пользователь:** wiener
* **Пароль:** peter

**Поведенческий анализ**

При добавлении товара в корзину используется следующий запрос:

```bash
productId=1&redir=PRODUCT&quantity=99
```

Этот параметр можно отправить **много раз** без строгого контроля накопленного значения.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-57d0ee5542db45b8f8a17c1c1128fad304658679%2Fimage%20(3101).png?alt=media" alt=""><figcaption></figcaption></figure>

Запрос отправляется в **Intruder** с пустой полезной нагрузкой, настроенной в **Продолжать бесконечно** режиме, и максимум **1 одновременный запрос**.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e6f606e8d1b9d1655ebf921062dbe505ec34876a%2Fimage%20(3102).png?alt=media" alt=""><figcaption></figcaption></figure>

После достаточного количества итераций **общая стоимость корзины становится отрицательной**.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9625ca79563b6a9a4c4b7b16de0b8b894016e9b1%2F%7B9260219F-93F4-425E-972E-02CE1FAE4B8F%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Причина проблемы**

Уязвимость связана со знаковым **переполнением**. / Приложение использует **знаковое 32-битное целое**, пределы которого:

* Минимальное значение : `-2 147 483 648`
* Максимальное значение : `2 147 483 647`

Когда сумма превышает максимально допустимое значение, она **пересчитывается в отрицательные значения** из-за арифметического переполнения.

**Недостаточные проверки**

Даже если приложение предотвращает оплату, когда итоговая сумма меньше 0, **во время промежуточных вычислений не выполняется корректная проверка**.

Это позволяет изменять корзину, пока не получится положительная, но очень маленькая итоговая сумма.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-39d129b1f470ca28aadbd71a1c9f9acb94653aa6%2Fimage%20(3104).png?alt=media" alt=""><figcaption></figcaption></figure>

**Корректировка итогового расчёта**

Чтобы получить сумму \*\*выше $0 и ниже $100\*\*, выполняется следующий расчёт:

* Стоимость куртки: **$1,337**
* Значение, необходимое для вызова переполнения: \**14 018 329* \*
* Расчёт:

  ```bash
  14 018 329 / 1337 ≈ 10 484 раз
  ```

Пакетная отправка (`quantity = 99`):

```bash
10 484 / 99 ≈ 105 запросов
```

**Итоговый состав корзины**

Чтобы получить допустимую итоговую сумму после переполнения:

* **32 123** куртки по $1337
* **21** обувь Baby minding за $60.79
* **Итоговая сумма:** **$54.63**


---

# 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/business-logic/low-level-logic-flaw.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.
