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





