← 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
- Load the script-context lab and submit a test name.
- Find the inline script block containing your reflected value.
- Close the JavaScript string and inject a statement that runs your code.
- Use comment syntax to neutralise trailing characters if needed.
- 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.