> 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

Notes sur le contournement de la connexion OAuth via le flux implicite pour les laboratoires de la PortSwigger Web Security Academy, incluant le workflow d’exploitation, les tests de payloads, la validation dans Burp Suite et le contexte de remédiation.

### 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 sur 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** (email : `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 pour vous connecter avec un réseau social… »*

<figure><img src="https://3840167291-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>

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

<figure><img src="https://3840167291-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://3840167291-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>

* 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 `nom d’utilisateur` les champs transmis par le client, au lieu de **strictement** lier ces valeurs à `token`.

```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 `token`:

<figure><img src="https://3840167291-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. Envoyer la requête modifiée.

#### Résultat

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

<figure><img src="https://3840167291-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/fr/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.
