CTF7
PricingFree tierFAQ Sign in

What is XSS in a CTF?

Cross-site scripting: running your script in another user's browser.

XSS, cross-site scripting, is a web vulnerability where an attacker injects a script that runs in other users' browsers, in the context of the vulnerable site. It can steal session data or act as the victim. It is cataloged as CWE-79.

Example

A comment box prints your text without escaping it. Posting this runs in the browser of anyone who views the comment:

<script>fetch('/admin/flag').then(r => r.text()).then(t => ...)</script>

CTF versions often include an admin bot that visits your page, so the script runs as the admin and can read a page you cannot. Stored XSS saves the payload on the server; reflected XSS returns it from a URL parameter.

How it is fixed

  • Escape output for the context it lands in.
  • Set a Content Security Policy.
  • Mark session cookies HttpOnly.

On CTF7

Web challenges that need a running application can run as isolated per-team lab instances, so your testing stays inside your team's environment. Raw Ops events score XSS reports by severity with CVSS 4.0.

Learn more

Read the web exploitation guide for worked examples and tools, or browse all CTF guides.

Browse the full CTF and cybersecurity glossary for more terms.

Plan your next event with us

A free jeopardy event for up to 50 players goes live when you publish it. For flagship events, our team can build the challenges and run the managed formats: attack-defense, King of the Hill and SOC simulations.

CTF7 mascot holding a CTF7 flag