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

# Low-Level Logic Failure

Low-Level Logic Failure notes for PortSwigger Web Security Academy labs, including exploitation workflow, payload testing, Burp Suite validation, and remediation context.

### Flawed Enforcement of Business Rules

**Description of lab**

This lab contains a \*\* logical defect in the purchasing process\*\*. Due to poor application of trade rules, it is possible to manipulate the calculation of the basket in order to buy a "Lightweight l33t leather jacket" at an unexpected price.

Identifier provided:

* **User:** wiener
* **Password:** peter

**Behavioral analysis**

When adding a product to the basket, the following query is used:

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

This parameter can be sent **a large number of times** without strict control of the cumulative value.

<figure><img src="https://131707722-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>

The query is sent to **Intruder** with a null payload configured in **Continue indefinitely** mode, and a maximum of **1 concurrent request**.

<figure><img src="https://131707722-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>

After enough iterations, the **total price of the basket becomes negative**.

<figure><img src="https://131707722-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>

**Cause of the problem**

Vulnerability comes from a signed **overflow**. / The application uses a **integer signed on 32 bits**, whose limits are:

* Valeur minimale : `-2 147 483 648`
* Valeur maximale : `2 147 483 647`

When the total exceeds the maximum permitted value, it **recalculates in negative values** due to arithmetical exceedance.

**Inadequate controls**

Even if the application prevents payment when the total is less than 0, **no correct verification is made during intermediate calculations**.

This allows you to adjust the basket until you get a positive but very low final amount.

<figure><img src="https://131707722-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>

**Final Calculation Adjustment**

To obtain an amount \*\* above $0 and below $100\*\*, the following calculation is made:

* Cost of jacket: **$1,337**
* Value required to cause overflow: \**14 018 329* \*
* Calculation:

  ```bash
  14 018 329 / 1337 ≈ 10 484 fois
  ```

Batch submission (`quantity = 99`):

```bash
10,484 / 99 ≈ 105 requests
```

**Final Cart Composition**

To obtain a valid total after overflow:

* **32 123** jackets at $1337
* **21** Baby minding shoes at $60.79
* **Final total:** **$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/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.
