Cross-Site Scripting (XSS) is a code injection attack where an attacker executes malicious JavaScript in a victim's browser. It is one of the most prevalent web vulnerabilities.
Why is it dangerous?
JavaScript has access to the DOM (Document Object Model), including:
- Cookies: Session IDs (if not HttpOnly).
- Local Storage: JWTs, user data.
- Forms: Can intercept keystrokes (keylogging).
- Network: Can make HTTP requests on behalf of the user (CSRF).
Essentially, if an attacker can run JS on your site, they are the user.