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

# XSS em um template literal com caracteres Unicode escapados

### XSS refletido em um literal de template com sinais de menor e maior, aspas simples, aspas duplas, barra invertida e backticks escapados em Unicode

XSS refletido em um literal de template (backticks) em que `<` e `>` os sinais de menor e maior, assim como as aspas simples e duplas, são codificados, e o backtick é escapado em Unicode. O objetivo: causar a execução de `alert()` dentro do template de string.

O parâmetro de busca é refletido em um literal de template do JavaScript. A string de template precisa ser quebrada para executar `alert()` a partir do valor refletido.

<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/6304ee61191871b90d25925df7b96cceebe85548" alt=""><figcaption></figcaption></figure>

* O caractere backtick (`` ` ``) delimita o literal de template; a página escapa o backtick fornecido pelo usuário (por exemplo, usando escape Unicode), impedindo uma fuga simples.

<figure><img src="/files/3bfb28bcea300729f9c6fab051481db2779833f9" alt=""><figcaption></figcaption></figure>

Exemplo da diferença de interpolação em JS (ilustração):

```javascript
variable = "Testing";
console.log("A variável é: ${variable}")
console.log(`A variável é: ${variable}`)
```

<figure><img src="/files/07fd6e6f9dd15ff7d0dcb267d2ba53f273d19c02" alt=""><figcaption></figcaption></figure>

A primeira linha exibe literalmente `${variable}`, a segunda interpreta a variável com backticks.

* Tentando inserir uma expressão de interpolação que executa `alert()`:

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

<figure><img src="/files/68bd88a604b0c7afec9927fa6adc639933eeb5a9" 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/pt-br/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.
