> 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/high-level-logic-vulnerability.md).

# Логическая уязвимость высокого уровня

### Уязвимость логики высокого уровня

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

В этой лабораторной работе данные, предоставляемые пользователем, проверяются некорректно. Логическую ошибку в процессе покупки можно использовать, чтобы изменить итоговую цену товаров. / Цель — купить \*\*

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

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

**Анализ работы корзины**

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

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

У `количество` параметр напрямую контролируется клиентом и на стороне сервера проверяется некорректно.

**Использование логической ошибки**

Если изменить количество, используя отрицательное значение, например:

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

Общая сумма корзины уменьшается, в результате чего получается отрицательная цена (например, \*\* $1337\*\*).

<figure><img src="/files/825f2f89be4e44866d20447b9feb632c1dd29b0f" alt=""><figcaption></figcaption></figure>

Однако при проверке корзины приложение блокирует этот случай сообщением:

> *Итоговая стоимость корзины не может быть меньше нуля*

<figure><img src="/files/87edc1482e5d357bbabf92d624065b7115cd8be3" alt=""><figcaption></figcaption></figure>

**Обход ограничения**

Чтобы эксплуатировать уязвимость:

Добавьте **целевая куртка** с допустимым количеством:

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

Затем добавьте другой товар с отрицательным количеством, чтобы уменьшить общую сумму:

```bash
productId=2&redir=PRODUCT&quantity=-100
```

Это приводит к сильно отрицательной общей сумме (например, **-$6241.00**).

<figure><img src="/files/01c6a94d35284a23a0a6aff7acf1fd3ebe04a0fe" alt=""><figcaption></figcaption></figure>

Измените отрицательное значение (например, `-17`) так, чтобы итоговая сумма оставалась **положительной**, но очень низкой (менее $100).

<figure><img src="/files/23015e473d39da4f5279fa4f6c49adcb9ea77bfa" 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/ru/web/business-logic/high-level-logic-vulnerability.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.
