Web App Security

What Is XSS (Cross-Site Scripting)? Definition, Architecture & Defense

Quick Definition: Cross-Site Scripting (XSS) is an injection vulnerability where untrusted data is rendered into a web page without context-aware output encoding, allowing an attacker to execute arbitrary JavaScript in another user browser session.

How XSS (Cross-Site Scripting) Works in Practice

Whether Stored (saved in a database comment/profile), Reflected (bounced off a URL parameter), or DOM-based (written via unsafe innerHTML sinks in client JS), XSS executes inside the victim origin. That gives the attacker script full access to the DOM, CSRF tokens, non-HttpOnly cookies, and authenticated API endpoints.

Defensive Mitigation & Hardening Checklist

Use modern auto-escaping UI templates, never pass untrusted strings to innerHTML or document.write without sanitization, mark session cookies HttpOnly, and deploy a strict Content-Security-Policy (CSP).

Hands-On Tool & Cheat Sheet


Related Security Glossary Terms