liveBook · Manning

Cross-site scripting attack

As explained in Acing the Frontend Interview

Cross-site scripting is an injection attack in which untrusted content causes scripts to execute in a user’s browser.

Cross-site scripting (XSS) occurs when untrusted content causes a script to run in a user’s browser. For an HTML form, the practical defense described here is to sanitize user input on the server before processing or storing it, removing or encoding potentially harmful scripts and HTML tags. section 2.4

If asked about form security in an interview, distinguish the safeguards:

  • Sanitization addresses XSS; validation checks expected formats and constraints, such as email addresses or numeric ranges. section 2.4
  • Anti-CSRF tokens protect form submissions from unintended actions; parameterized queries address SQL injection in database interactions. section 2.4

How Acing the Frontend Interview covers it

How deep it goes
Explains server-side sanitization as removing or encoding harmful content, without an attack walkthrough or sanitization code.
Examples
Uses potentially harmful scripts and HTML tags as input to remove or encode; provides no XSS payload.
What you can do after
Practice/perform server-side sanitization of form input and distinguish it from validation and other security safeguards.
How it connects
Connects XSS to input sanitization, input validation, CSRF, and SQL injection as distinct form-security concerns.

Also explained in

Compare how 6 books explain cross-site scripting attack →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Frontend Interview. The section links point to the parts of the book it draws on.