Skip to content
XSS Write-up Intermediate

Reflected XSS Into a Template Literal With Angle Brackets, Single, Double Quotes, Backslash and Backticks Unicode-Escaped

User input is reflected into a JavaScript template literal, and although angle brackets, quotes, backslashes and backticks are Unicode-escaped, the `${...}` expression syntax is not neutralised. An attacker can inject a template expression that executes arbitrary JavaScript in the victim's browser.

Bash Overflow Follow

Published on bashoverflow.com

This vulnerability lies in how a JavaScript template literal is constructed dynamically from user input. In this lab, user input is reflected into a JavaScript template string that appears in the rendered page.

Bash Overflow, on bashoverflow.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the application escaped characters that could break out of the string but failed to neutralise the `${...}` expression syntax, which is evaluated inside template literals.

Impact

A successful XSS could lead to session hijacking, credential theft, and redirection to malicious sites.

What the attacker needed

Victim clicks a crafted link

How it was found

  1. Open the lab.
  2. Try injecting a basic payload and observe that characters are blocked or sanitised.
  3. Use Burp Suite Repeater to test URL-encoded and Unicode-encoded variations, which also fail.
  4. Try HTML entity encoding, which also fails.
  5. Inject a payload using the `${...}` template literal expression syntax, URL-encoded.
  6. Show the response in the browser and observe the alert popup, confirming XSS.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A template literal is a way to build strings in JavaScript using backticks, and it allows embedding expressions with ${...}. The site put user input inside such a string but only escaped some characters, forgetting that ${...} still works. So an attacker could make the page run their own script.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Bash Overflow

View all

35 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.