> For the complete documentation index, see [llms.txt](https://sayonara.gitbook.io/writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sayonara.gitbook.io/writeups/portswigger/xss/21-reflected-xss-into-a-template-literal-with-angle-brackets-single-double-quotes-backslash-and-back.md).

# 21) Reflected XSS into a template literal with angle brackets, single, double quotes, backslash and backticks Unicode-escaped

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FnVLs2TKnZFotiwi6Ps4h%2Fimage.png?alt=media&amp;token=1a6364fc-4cce-499e-8be6-1712a7f5fde5" alt=""><figcaption></figcaption></figure></div>

#### Locate possible injection points

As usual the first step is to analyse the application, we have a search functionnality so let's search for random string and then open the developer tools and find where the user input is located in the html

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FLur2gUydkj935GnGmBsR%2Fimage.png?alt=media&amp;token=4a6e2db9-6f8a-4108-8fa8-e4b87e9cba91" alt=""><figcaption></figcaption></figure></div>

as we see our input is reflected in a template literal

### template literal

JavaScript template literals are string literals that allow embedded JavaScript expressions. The embedded expressions are evaluated and are normally concatenated into the surrounding text. Template literals are encapsulated in backticks instead of normal quotation marks, and embedded expressions are identified using the `${...}` syntax.

then you can use the following payload to execute JavaScript without terminating the template literal:

```
${alert(1)}
```

### payload

```
xxxx${alert(1)}
```

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FBhZ0I1GeAhkw0Vd4PBvQ%2Fimage.png?alt=media&amp;token=f674aa2f-f733-46fe-800f-d07bcd9a126d" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2F9PoRzEqMUmLSB1ZOcfWi%2Fimage.png?alt=media&amp;token=44e5e7f9-d74f-4820-a272-ddc0eefeceae" alt=""><figcaption></figcaption></figure></div>

and we have solved the lab

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FSVTtONhQ3HPbwGJq3xMW%2Fimage.png?alt=media&amp;token=e98e9396-dc44-4bf3-b0a6-38b7c207510a" alt=""><figcaption></figcaption></figure></div>
