Cross-Site Scripting
Cross-Site Scripting is a web security vulnerability that allows attackers to inject malicious code into legitimate or trusted websites. When a user visits the affected website, the malicious code executes in their web browser, potentially allowing the attacker to steal information or impersonate the user. It is one of the most common types of web application security flaws.
Cross-Site Scripting (XSS) is a client-side code injection vulnerability found in web applications where an attacker is able to insert malicious scripts, typically JavaScript, into web pages served to other users. The vulnerability arises when an application includes untrusted data in its output without proper validation, encoding, or escaping, allowing the injected script to execute within the victim's browser in the context of the vulnerable application's origin. This can compromise the interactions that users have with the application, enabling actions such as session hijacking, credential theft, DOM manipulation, or redirection to attacker-controlled sites. XSS vulnerabilities are commonly categorized into reflected (non-persistent), stored (persistent), and DOM-based variants, each differing in how the malicious payload is delivered and executed.
Why it matters
Cross-Site Scripting remains one of the most prevalent web application security vulnerabilities, consistently appearing in industry vulnerability rankings and affecting organizations of all sizes. Because XSS exploits the trust a user's browser places in a legitimate website, successful attacks can lead to session hijacking, credential theft, unauthorized actions performed on behalf of the victim, and the delivery of further malicious payloads. The impact can range from defacement and phishing to full account takeover, depending on the context of the vulnerable application and the privileges of the targeted user.
XSS is particularly dangerous because it targets end users rather than the server itself, which means traditional server-side defenses may not detect or prevent exploitation. Stored XSS variants are especially concerning, as a single injected payload can affect every user who visits the compromised page, potentially scaling the attack to thousands of victims without any further action from the attacker. The broad attack surface (any point where user-supplied data is reflected or rendered in a page can be a potential injection point) makes XSS a persistent challenge for development and security teams alike.
For organizations, the consequences extend beyond immediate technical impact. XSS vulnerabilities can erode user trust, expose sensitive customer data, and create regulatory and compliance risks. Addressing XSS effectively requires a combination of secure coding practices, input validation, output encoding, and layered browser-side defenses such as Content Security Policy, making it a concern that spans the entire software development lifecycle.
Who it's relevant to
Inside XSS
Common questions
Answers to the questions practitioners most commonly ask about XSS.