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

# Fallo de lógica de bajo nivel

Notas sobre Fallo de lógica de bajo nivel para los laboratorios de PortSwigger Web Security Academy, incluido el flujo de explotación, pruebas de payload, validación en Burp Suite y contexto de mitigación.

### Aplicación defectuosa de las reglas de negocio

**Descripción del laboratorio**

Este laboratorio contiene un \*\*defecto lógico en el proceso de compra\*\*. Debido a la mala aplicación de las reglas comerciales, es posible manipular el cálculo del carrito para comprar una "Lightweight l33t leather jacket" a un precio inesperado.

Identificador proporcionado:

* **Usuario:** wiener
* **Contraseña:** peter

**Análisis del comportamiento**

Al añadir un producto al carrito, se utiliza la siguiente consulta:

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

Este parámetro puede enviarse **un gran número de veces** sin un control estricto del valor acumulado.

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

La consulta se envía a **Intruder** con una carga nula configurada en **Continuar indefinidamente** modo, y un máximo de **1 solicitud concurrente**.

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

Después de suficientes iteraciones, el **precio total del carrito se vuelve negativo**.

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

**Causa del problema**

La vulnerabilidad proviene de un desbordamiento **con signo**. / La aplicación usa un **entero con signo de 32 bits**, cuyos límites son:

* Valor mínimo: `-2 147 483 648`
* Valor máximo: `2 147 483 647`

Cuando el total supera el valor máximo permitido, lo **recalcula en valores negativos** debido a un desbordamiento aritmético.

**Controles inadecuados**

Incluso si la aplicación impide el pago cuando el total es menor que 0, **no se realiza una verificación correcta durante los cálculos intermedios**.

Esto le permite ajustar el carrito hasta obtener un importe final positivo pero muy bajo.

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

**Ajuste del cálculo final**

Para obtener un importe \*\* superior a $0 e inferior a $100\*\*, se realiza el siguiente cálculo:

* Costo de la chaqueta: **$1,337**
* Valor necesario para provocar el desbordamiento: \**14 018 329* \*
* Cálculo:

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

Envío por lotes (`cantidad = 99`):

```bash
10 484 / 99 ≈ 105 solicitudes
```

**Composición final del carrito**

Para obtener un total válido después del desbordamiento:

* **32 123** chaquetas a $1337
* **21** zapatos Baby minding a $60.79
* **Total final:** **$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/es/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.
