> 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/single-endpoint-race-condition.md).

# Condição de Corrida em Endpoint Único

### Condições de corrida de endpoint único

### Contexto do laboratório

O recurso de alteração de endereço de e-mail contém uma **condição de corrida** que permite associar um endereço arbitrário à nossa conta.

Um usuário com o endereço **<carlos@ginandjuice.shop>** tem um **convite pendente** para se tornar administrador, mas **ainda não criou uma conta**. / Então, se alguém conseguir **revender este endereço**, ele recupera automaticamente os **direitos de administrador**.

### Objetivo

1. Encontre uma condição de corrida para reivindicar um endereço de e-mail arbitrário.
2. Altere o e-mail da conta para **<carlos@ginandjuice.shop>**.
3. Acesse o **painel de administração**.
4. Excluir usuário **carlos**.

Credenciais fornecidas: **wiener:peter**/ Acesso a um cliente de e-mail para endereços **@exploit-...exploit-server.net**.

### Fluxo normal de alteração de e-mail

A primeira tentativa é alterar o e-mail para um endereço controlado:

* Novo endereço:/ `wiener@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net`

<figure><img src="/files/0886243e8c76b94d765167c24a4cbbb941404d9a" alt=""><figcaption></figcaption></figure>

Resposta da aplicação:

> “Por favor, clique no link no seu e-mail para confirmar a alteração do e-mail para …”

<figure><img src="/files/2d260d22f93778766dc07be190fa7191b34c911c" alt=""><figcaption></figcaption></figure>

Chega um e-mail com um link de confirmação, por exemplo:/ `/confirm-email?user=wiener&token=ob0dI7AMlwX2Y2uw`

Assim que o link é clicado:

> “Seu e-mail foi atualizado com sucesso”

<figure><img src="/files/42d5be7c8af4095217f4d1c9572a0555757f3fdd" alt=""><figcaption></figcaption></figure>

Por trás, a requisição se parece com:

```bash
email=wiener%40exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk
```

### Teste de base sem corrida

Enviamos várias requisições de alteração de e-mail, com e-mails diferentes (test1, test2,... test20), cada uma separadamente, e as confirmações recebidas correspondem corretamente aos endereços solicitados.

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

```bash

email=test1@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test2@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test3@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test4@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test5@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test6@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test7@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test8@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk
.....

email=test20@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk
```

<figure><img src="/files/652e9c68978e88a76671babf042e8937218426f5" alt=""><figcaption></figcaption></figure>

Mas quando você executa essas mesmas requisições **em paralelo**, um comportamento inesperado aparece: às vezes você recebe confirmações que não correspondem ao destinatário correto.

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

<figure><img src="/files/2c06d41c938c7a7fba6e5dc71848bc1a957c62c5" alt=""><figcaption></figcaption></figure>

### Análise da condição de corrida

O comportamento observado sugere processamento em duas fases\*\*:

1. Uma fase que **prepara/escreve** e-mail de confirmação
2. Uma fase que **determina qual endereço** o e-mail é enviado

Ao enviar um lote de requisições em paralelo, conseguimos cruzar essas duas fases: o conteúdo de um e-mail pode ser associado a outro endereço de destino.

Princípio: enviar em paralelo uma mistura de requisições contendo:

Parte com:

```bash
email=carlos@ginandjuice.shop&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk
```

Outra parte com um endereço controlado:

```bash
email=test@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk
```

Resultado: recebemos um e-mail dizendo:

> “Para confirmar sua alteração de e-mail para **<carlos@ginandjuice.shop>**, clique no link abaixo”

<figure><img src="/files/139d93d79b7e02f6334eb6199960c99c099ce77b" alt=""><figcaption></figcaption></figure>

Assim, obtemos o **link de confirmação** para o endereço de Carlos e podemos finalizar a alteração do e-mail para **<carlos@ginandjuice.shop>**.

<figure><img src="/files/af2d2a64d92df105de66b62890587bae86b03525" 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/single-endpoint-race-condition.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.
