Cross-site scripting (XSS) is a vulnerability that allows malicious code to be injected into web applications. There are two types: reflected (non-persistent) XSS occurs when malicious code is reflected off a web server in responses like errors or search results. Stored (persistent) XSS occurs when malicious code is saved in a database and then displayed to users. XSS attacks can steal user cookies and private information, redirect users to malicious sites, and perform actions as the victim.