> 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/oauth-authentication/oauth-login-bypass-via-implicit-flow.md).

# Contorno de Login OAuth via Fluxo Implícito

### Bypass de autenticação via fluxo implícito do OAuth

#### Contexto do laboratório

Este laboratório usa um **OAuth** provedor para permitir a conexão via uma conta de rede social. / Devido a uma insuficiente **validação na aplicação cliente**, é possível conectar-se a outra conta de usuário **sem saber sua senha**.

Objetivo: conectar-se como **carlos** (e-mail: `carlos@carlos-montoya.net`). / Conta de mídia social disponível: `wiener:peter`.

#### Observações

* Ao tentar fazer login, a aplicação redireciona para uma página OAuth:
  * *“Agora estamos redirecionando você para fazer login com a mídia social...”*

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

* Após a autenticação no domínio OAuth e a aceitação das permissões (perfil + e-mail), a aplicação então envia uma solicitação para um endpoint interno, normalmente:
* `POST /authenticate`

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

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

* Esta solicitação contém um JSON do tipo:

{% code overflow="wrap" %}

```json
{
"email":"wiener@hotdog.com",
"username":"wiener",
"token":"MkydN3cYAC6wsKXQJEd5tD3kW1nB9MoWqzdfhyL6BtE"
}
```

{% endcode %}

Ponto-chave: a aplicação **confia em** o `email` e `nome de usuário` nos campos transmitidos pelo cliente, em vez de **rigorosamente** vincular esses valores a `token`.

```json
{
"email":"carlos@carlos-montoya.net",
"username":"carlos",
"token":"MkydN3cYAC6wsKXQJEd5tD3kW1nB9MoWqzdfhyL6BtE"
}
```

#### Exploração

1. Normalmente, conectar-se via OAuth com a conta **wiener**.
2. Intercepte a solicitação enviada para `POST /authenticate`.
3. Altere apenas os campos de identidade, mantendo o mesmo `token`:

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

4. Envie a solicitação modificada.

#### Resultado

* O servidor responde **`302 Found`**, o que indica que a sessão foi criada e que a aplicação considera o usuário autenticado.
* Então obtemos uma sessão \*\*conectada como Carlos\*\*.

<figure><img src="/files/069a5948422039ef76278a3d0242c0da6cbb11b0" 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/oauth-authentication/oauth-login-bypass-via-implicit-flow.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.
