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

# Vulnerabilidad lógica de alto nivel

### Vulnerabilidad lógica de alto nivel

**Descripción del laboratorio**

Este laboratorio no valida correctamente los datos proporcionados por el usuario. Es posible explotar un fallo lógico en el proceso de compra para cambiar el precio final de los artículos. / El objetivo es comprar el \*\*

Identificador proporcionado:

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

**Análisis del funcionamiento de la cesta**

Cuando se añade un producto a la cesta, la solicitud enviada tiene este aspecto:

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

El `cantidad` el parámetro está directamente controlado por el cliente y no se comprueba correctamente en el lado del servidor.

**Explotación del fallo lógico**

Si la cantidad se cambia usando un valor negativo, por ejemplo:

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

El importe total de la cesta disminuye, lo que da como resultado un precio negativo (por ejemplo, \*\* $1337\*\*).

<figure><img src="/files/82974a4fac80681c03becd975f00310438084f73" alt=""><figcaption></figcaption></figure>

Sin embargo, al validar la cesta, la aplicación bloquea este caso con el mensaje:

> *El precio total del carrito no puede ser inferior a cero*

<figure><img src="/files/eebad8535357d8263cb56ae77c652002fc5f6420" alt=""><figcaption></figcaption></figure>

**Evasión de la restricción**

Para explotar la vulnerabilidad:

Añadir el **chaqueta objetivo** con una cantidad válida:

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

Luego añade otro producto con una cantidad negativa para reducir el total:

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

Esto da como resultado un total muy negativo (por ejemplo, **-$6241.00**).

<figure><img src="/files/bfa8db4b195c8a60ec7cd2452af03f7e25c5b144" alt=""><figcaption></figcaption></figure>

Ajusta la cantidad negativa (por ejemplo, `-17`) para que el total final permanezca **positivo**, pero muy bajo (menos de $100).

<figure><img src="/files/a048da3d53085366c7a8b412e80cde0f5bf5880d" 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/es/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.
