Skip to content
XSS Write-up Beginner

String Me Along: How a Single Quote Unraveled a Site’s Security

A welcome-message script built a JavaScript string from a URL parameter and passed it to eval(), so a single quote in the parameter let an attacker break out of the string and run their own code. The author shows that this could run arbitrary script in a victim's browser and exfiltrate session cookies.

medium.com

Published on medium.com

A critical Client-Side Template Injection (CSTI) vulnerability was discovered in a web application’s welcome message functionality. The vulnerability stemmed from the dangerous use of the eval() function to execute a string of code built from unsanitized user input.

Buffer, on medium.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 user input from the URL was concatenated into a JavaScript string that was then executed with eval(), and the only filter blocked the less-than character rather than the quote needed to escape the string.

Impact

An attacker could run arbitrary JavaScript in a victim's browser, which the author says could lead to session hijacking, defacement or full account takeover by stealing cookies.

What the attacker needed

Victim opens a crafted link; no account needed to view the page

How it was found

  1. Open the page and view its source to find the inline script.
  2. Notice the script reads a 'user' parameter from the URL and builds a command string from it.
  3. Add a user parameter to the URL and confirm the value appears in the welcome message.
  4. Supply a value containing a quote to close the string, then injected code, then a comment to hide the rest.

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.

The page took a value from the web address and glued it into a line of JavaScript, then ran that line with a function called eval, which executes text as code. Because the value was not cleaned, typing a quote mark ended the intended text early and let the attacker add their own instructions. The result is that the attacker's code runs in the browser of anyone who opens the crafted link.

What is XSS?

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

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.