← back to room
XSS

XSS in a Script Block

Scenario

Greetly added analytics that embed the visitor's name inside an inline JavaScript string. The page assigns your input to a variable before logging it to the console. Escape the string context without breaking the surrounding script syntax.

Your approach

  1. Load the script-context lab and submit a test name.
  2. Find the inline script block containing your reflected value.
  3. Close the JavaScript string and inject a statement that runs your code.
  4. Use comment syntax to neutralise trailing characters if needed.
  5. Capture the flag shown after successful execution and submit it.
The value lands inside var name = '...'. Break out of the string and execute JS — the flag will appear.

Personalise