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

# Contournement de la connexion OAuth via le flux implicite

### Contournement de l’authentification via le flux implicite OAuth

#### Contexte du laboratoire

Ce laboratoire utilise un **OAuth** fournisseur pour permettre la connexion via un compte de réseau social. / En raison d'une insuffisante **validation dans l'application cliente**, il est possible de se connecter à un autre compte utilisateur **sans connaître son mot de passe**.

Objectif : se connecter en tant que **carlos** (e-mail : `carlos@carlos-montoya.net` ). / Compte de réseau social disponible : `wiener:peter`.

#### Observations

* Lors de la tentative de connexion, l'application redirige vers une page OAuth :
  * *« Nous vous redirigeons maintenant vers la connexion via un réseau social... »*

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

* Après l'authentification sur le domaine OAuth et l'acceptation des autorisations (profil + e-mail), l'application envoie ensuite une requête vers un point de terminaison interne, généralement :
* `POST /authenticate`

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

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

* Cette requête contient un JSON du type :

{% code overflow="wrap" %}

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

{% endcode %}

Point clé : l'application **fait confiance à** le `email` et `le nom d'utilisateur` aux champs transmis par le client, au lieu de **strictement** lier ces valeurs à `jeton`.

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

#### Exploitation

1. Se connecter normalement via OAuth avec le compte **wiener**.
2. Intercepter la requête envoyée à `POST /authenticate`.
3. Modifier uniquement les champs d'identité, en conservant le même `jeton`:

<figure><img src="/files/0481de9c9eb306d1f20d27d3d788d3610af58f6c" alt=""><figcaption></figcaption></figure>

4. Envoyer la requête modifiée.

#### Résultat

* Le serveur répond **`302 Found`**, ce qui indique que la session est créée et que l'application considère l'utilisateur authentifié.
* On obtient alors une session \*\*connectée en tant que Carlos\*\*.

<figure><img src="/files/cb879841c4e85ceaa5615055bca3c55c7553f761" 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/fr/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.
