> 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/websockets/websocket-message-manipulation.md).

# Manipulation von WebSocket-Nachrichten

### Manipulieren von WebSocket-Nachrichten zur Ausnutzung von Schwachstellen

Dieser Online-Shop verfügt über eine Echtzeit- **Chatfunktion** implementiert mit **WebSockets**. / Vom Benutzer gesendete Nachrichten werden sofort im Browser eines **Support-Mitarbeiters**. / Das Ziel des Labors ist es, **ein `alert()`** Popup-Fenster im Browser des Mitarbeiters durch Manipulation einer WebSocket-Nachricht auszulösen.

In der App gibt es ein Chatfeld.

<figure><img src="/files/3b2ae8ca160ef27d1d61e1c536e63d9ab857ba25" alt=""><figcaption></figcaption></figure>

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

Durch die Analyse des Datenverkehrs werden Nachrichten per WebSocket wie folgt gesendet:

```json
{
    "user":"Du",
    "content":"hi"
}
```

**Filtertest**

Versuchen Sie, die folgende Payload über den Chat zu senden:

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

Beobachtetes Ergebnis\:/ Der Inhalt wird \*\* auf der Serverseite maskiert\*\* und als Text interpretiert:

```javascript
&lt;script&gt;alert(0)&lt;/script&gt;
```

<figure><img src="/files/5b4b8307ffafe251b79b26d2f7635ed8b7bf5475" alt=""><figcaption></figcaption></figure>

Dies weist auf eine grundlegende Filterung gegen `<script>` Tags hin.

**Umgehung der Filterung**

Anschließend wird manuell eine WebSocket-Nachricht mit der folgenden Payload gesendet:

```http
<img src=0 onerror=alert(0)>
```

Die Nachricht wird **direkt weitergeleitet** über die WebSocket-Anfrage, ohne die üblichen Steuerelemente der Benutzeroberfläche zu durchlaufen.

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

Wenn der Support-Mitarbeiter die Nachricht empfängt, interpretiert der Browser das `onerror` Attribut, wodurch Folgendes ausgelöst wird:

* Ausführung von `alert(0)`
* Das Erscheinen eines **Popup-Fensters** im Browser des Mitarbeiters

<figure><img src="/files/0d2f6741c903f53179ef54706bec52fa887ed972" 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/de/web/websockets/websocket-message-manipulation.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.
