> 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/xss-in-template-literal-with-escaped-unicode.md).

# エスケープされたUnicode文字を含むリテラルテンプレート内のXSS

PortSwigger Web Security Academy のラボ向けメモ。エスケープされたUnicode文字を含むリテラルテンプレート内のXSSに関するもので、攻撃手順、ペイロードのテスト、Burp Suite による検証、および対策 cont

### 山括弧、シングルクォート、ダブルクォート、バックスラッシュ、およびバッククォートがUnicodeエスケープされたテンプレートリテラルへの反射型XSS

XSSがリテラルテンプレート（バッククォート）に反映される場合、 `<` および `>` 山括弧やシングルクォート、ダブルクォートはエンコードされ、バッククォートはUnicodeでエスケープされます。目的は、実行させること `alert()` 文字列テンプレート内で。

検索パラメータはJavaScriptのリテラルテンプレートに反映されます。テンプレート文字列を壊して実行する必要があります `alert()` 反映された値から。

<pre class="language-javascript"><code class="lang-javascript">var message = `test の検索結果は 2 件です`;
<strong>document.getElementById('searchMessage').innerText = message;
</strong></code></pre>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9e01c413822a528e8f8d508cfceb5670682a6e59%2Fimage%20(416).png?alt=media" alt=""><figcaption></figcaption></figure>

* バッククォート文字（`` ` ``) がテンプレートリテラルを区切ります。ページはユーザー提供のバッククォートを（たとえばUnicodeエスケープを使って）エスケープするため、単純な脱出はできません。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cd683beaa7d8cf19d1e69181029ae28e5e62a1e4%2Fimage%20(417).png?alt=media" alt=""><figcaption></figcaption></figure>

JSの補間の違いの例（図示）:

```javascript
variable = "テスト中";
console.log("変数は次のとおりです: ${variable}")
console.log(`変数は次のとおりです: ${variable}`)
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0c6d0eada5a823250cbb20521a0c5dffabd0b8aa%2Fimage%20(418).png?alt=media" alt=""><figcaption></figcaption></figure>

1行目は文字通り表示します `${variable}`、2行目はバッククォートで変数を解釈します。

* 実行される補間式を挿入しようとしている `alert()`:

```javascript
${alert(0)}
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ab6acd9b60a371feb6d804be4b5282f96fee3f97%2Fimage%20(419).png?alt=media" alt="" width="520"><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/xss/xss-in-template-literal-with-escaped-unicode.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.
