Cross-site scripting (XSS)
An attack where a page shows untrusted input, like a comment, without cleaning it, so the attacker's script runs in other users' browsers and can steal cookies. Escape output to stop it.
Understanding Cross-site scripting (XSS) in ACARA Digital Technologies Years 9–10
What it does: Replacing < and > with < and > means the browser displays the tag as plain text rather than running it. Calling an escape or sanitise function on the comment before it is displayed removes the chance for it to run as code. XSS happens when a page displays untrusted input, like a comment, without cleaning it, so the script runs in other people's browsers. A script running in the visitor's browser can read cookies. A stolen session cookie can let the attacker pretend to be that user. Escaping changes < to < so the browser treats it as text to display, not as a tag to run.
Common mistakes: The comment is untrusted input. Adding it to the page without escaping lets a script typed into the comment box run in other users' browsers. It should be html ← "<p>" + escape(comment). strip() only removes spaces at the ends of the text. It does not turn < and > into harmless characters, so a script would still run. It should be safe = html.escape(c).
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 782–809) and word search (Modules 743–809).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
XSSFill in the Blanks
Spot the Error
Student with a class code? Join your class →