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

# Bypass de inicio de sesión OAuth mediante flujo implícito

Notas sobre Bypass de inicio de sesión OAuth mediante flujo implícito para los laboratorios de PortSwigger Web Security Academy, incluido el flujo de explotación, pruebas de payload, validación en Burp Suite y contexto de mitigación.

### Bypass de autenticación mediante el flujo implícito de OAuth

#### Contexto del laboratorio

Este laboratorio utiliza un **OAuth** proveedor para habilitar la conexión mediante una cuenta de red social. / Debido a una insuficiente **validación en la aplicación cliente**, es posible conectarse a la cuenta de otro usuario **sin conocer su contraseña**.

Objetivo: conectarse como **carlos** (correo electrónico: `carlos@carlos-montoya.net`). / Cuenta de redes sociales disponible: `wiener:peter`.

#### Observaciones

* Al intentar iniciar sesión, la aplicación redirige a una página de OAuth:
  * *“Ahora te estamos redirigiendo para iniciar sesión con redes sociales...”*

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d78b6220dc9e14aead6ae2bf57ba88b5dbf0e24a%2Fimage%20(185).png?alt=media" alt=""><figcaption></figcaption></figure>

* Después de la autenticación en el dominio OAuth y la aceptación de permisos (perfil + correo electrónico), la aplicación envía entonces una solicitud a un endpoint interno, normalmente:
* `POST /authenticate`

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-20a4e57d883029f70fd46441e0fffaae8f87b37c%2Fimage%20(186).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-30325b94a6266f6bf57eafb9957cb7eeec0da1f9%2Fimage%20(187).png?alt=media" alt=""><figcaption></figcaption></figure>

* Esta solicitud contiene un JSON del tipo:

{% code overflow="wrap" %}

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

{% endcode %}

Punto clave: la aplicación **confía** el `correo electrónico` y `nombre de usuario` en los campos transmitidos por el cliente, en lugar de **estrictamente** vincular estos valores a `token`.

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

#### Explotación

1. Normalmente inicia sesión mediante OAuth con la cuenta **wiener**.
2. Intercepta la solicitud enviada a `POST /authenticate`.
3. Cambia solo los campos de identidad, manteniendo el mismo `token`:

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-97f224ef92349900ec012be9b8849294c618a50a%2Fimage%20(188).png?alt=media" alt=""><figcaption></figcaption></figure>

4. Envía la solicitud modificada.

#### Resultado

* El servidor responde **`302 Encontrado`**, lo que indica que la sesión se ha creado y que la aplicación considera que el usuario está autenticado.
* Entonces obtenemos una sesión \*\* conectada como Carlos\*\*.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-598ec1956f60ccd7fb4a4c70d306305701aa085e%2Fimage%20(189).png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/es/web/oauth-authentication/oauth-login-bypass-via-implicit-flow.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
