> 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

### 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 de la cesta para comprar una "chaqueta de cuero l33t ligera" a un precio inesperado.

Identificador proporcionado:

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

**Análisis de comportamiento**

Cuando se añade un producto a la cesta, 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="/files/1e39c329e717f226ba1118b9cd2501c6c7e45766" alt=""><figcaption></figcaption></figure>

La consulta se envía a **Intruder** con un payload nulo configurado en **Continuar indefinidamente** modo, y un máximo de **1 solicitud concurrente**.

<figure><img src="/files/84da0add1f3698d51bf990c698e7249e6f6bb146" alt=""><figcaption></figcaption></figure>

Después de suficientes iteraciones, el **precio total de la cesta se vuelve negativo**.

<figure><img src="/files/8eb2db190ff222e581ae6b6057b7c31560945a06" alt=""><figcaption></figcaption></figure>

**Causa del problema**

La vulnerabilidad proviene de un **desbordamiento**. / La aplicación utiliza 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, este **se recalcula en valores negativos** debido a un desbordamiento aritmético.

**Controles inadecuados**

Aunque 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 permite ajustar la cesta hasta obtener un importe final positivo pero muy bajo.

<figure><img src="/files/62f886a3ed65406bb8fa0eaed6295db5ff5609c6" alt=""><figcaption></figcaption></figure>

**Ajuste final del cálculo**

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

* Coste 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 de la cesta**

Para obtener un total válido tras el desbordamiento:

* **32 123** chaquetas a $1337
* **21** zapatos para el cuidado de bebés 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 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/es/web/business-logic/low-level-logic-flaw.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.
