COURSE: Web Application Security Fundamentals
WEEK 1 — Introduction to XSS & Client-Side Attacks
INSTRUCTOR: Prof. David Reeves
SLIDE DECK: Week 1 / Lecture 1
=========================================================
SLIDE 1: What is Cross-Site Scripting?
---------------------------------------
Cross-Site Scripting (XSS) is a code injection vulnerability that allows
attackers to inject malicious scripts into web pages viewed by other users.
Types of XSS:
1. Reflected XSS — payload in request, reflected in response
2. Stored XSS — payload persisted in the database
3. DOM-Based XSS — payload executed via client-side JS
SLIDE 2: Attack Surface
---------------------------------------
Common injection points:
- URL query parameters
- Form inputs (search boxes, comments)
- HTTP headers (User-Agent, Referer)
- JSON API responses rendered without encoding
SLIDE 3: Vulnerable Code Pattern
---------------------------------------
PHP: echo $_GET['name']; // No sanitization
JS: document.innerHTML = location.hash // DOM sink
Safe alternative:
PHP: echo htmlspecialchars($_GET['name'], ENT_QUOTES, 'UTF-8');
JS: element.textContent = value; // Not innerHTML
SLIDE 4: Lab Exercise
---------------------------------------
Target: http://vuln-app.local/search?q=
Goal: Trigger alert(1) in the browser
Try:
">