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

# XSS в литеральном шаблоне с экранированными Unicode-символами

### Отражённый XSS в шаблонном литерале с угловыми скобками, одинарными и двойными кавычками, обратной косой чертой и обратными кавычками, экранированными в Unicode

XSS, отражённый в шаблонном литерале (обратные кавычки), где `<` и `>` угловые скобки, а также одинарные и двойные кавычки закодированы, а обратная кавычка экранирована в Unicode. Цель: вызвать выполнение `alert()` внутри строкового шаблона.

Параметр поиска отражается в шаблонном литерале JavaScript. Строку шаблона нужно разорвать, чтобы выполнить `alert()` из отражённого значения.

<pre class="language-javascript"><code class="lang-javascript">var message = `2 search results for 'test'`;
<strong>document.getElementById('searchMessage').innerText = message;
</strong></code></pre>

<figure><img src="/files/1bcd6a3a408a4808ac9d9c674f461cc5a34809d8" alt=""><figcaption></figcaption></figure>

* Символ обратной кавычки (`` ` ``) ограничивает шаблонный литерал; страница экранирует переданную пользователем обратную кавычку (например, с помощью Unicode-экранирования), предотвращая простой выход за его пределы.

<figure><img src="/files/69d4bc5170e6d92f0d76f3f519a32153763ec326" alt=""><figcaption></figcaption></figure>

Пример различия в интерполяции JS (иллюстрация):

```javascript
variable = "Testing";
console.log("The variable is: ${variable}")
console.log(`The variable is: ${variable}`)
```

<figure><img src="/files/4188b62aa29e0f5362bfd834a3eafe27dd3387f7" alt=""><figcaption></figcaption></figure>

Первая строка буквально отображает `${variable}`, а вторая интерпретирует переменную с помощью обратных кавычек.

* Попытка вставить выражение интерполяции, которое выполняет `alert()`:

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

<figure><img src="/files/0dc14b706797fa37028f98ebeaef24afe87ac349" 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 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/ru/web/xss/xss-in-template-literal-with-escaped-unicode.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.
