What is CWE-79?
The product fails to neutralize, or incorrectly neutralizes, user-controlled input before placing it in web page output served to other users. This permits dangerous input to be interpreted as active content by the browser.
The product fails to neutralize, or incorrectly neutralizes, user-controlled input before placing it in web page output served to other users. This permits dangerous input to be interpreted as active content by the browser.
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
There are many variants of cross-site scripting, characterized by a variety of terms or involving different attack topologies. However, they all indicate the same fundamental weakness: improper neutralization of dangerous input between the adversary and a victim.
The Same Origin Policy states that browsers should limit the resources accessible to scripts running on a given web site, or "origin", to the resources associated with that web site on the client-side, and not the client-side resources of any other sites or "origins". The goal is to prevent one site from being able to modify or read the contents of an unrelated site. Since the World Wide Web involves interactions between many sites, this policy is important for browsers to enforce.
When referring to XSS, the Domain of a website is roughly equivalent to the resources associated with that website on the client-side of the connection. That is, the domain can be thought of as all resources the browser is storing for the user's interactions with this particular site.
Cross-site scripting, commonly abbreviated as XSS, is a family of weaknesses with different delivery paths and attack topologies, but the same underlying failure: dangerous input is not properly neutralized between an adversary and a victim. It can occur when input is reflected directly from an HTTP request, stored in a trusted data store and later rendered, or inserted by a client-side application through the DOM. The browser's same-origin protections are intended to separate a site's client-side resources from those of other origins, but injected script can execute in the context of the affected site and gain access to resources available to that origin.
This is a base, simple, stable weakness introduced during implementation and is not specific to a programming language. Common forms include reflected or non-persistent XSS, stored or persistent XSS, and DOM-based XSS. Untrusted data may enter through parameters, cookies, network input, environment variables, reverse DNS results, query results, request headers, URL components, email, files, filenames, databases, external systems, or indirect API calls. XSS is common in web-based technology, but the record also identifies web servers and AI/ML technology as applicable platforms.
XSS can compromise confidentiality, integrity, availability, and access control. A script may read application data such as session information in cookies, perform actions on behalf of a victim, bypass protection mechanisms, expose confidential information, redirect users, alter page presentation, disclose end-user files, install Trojan horse programs, or run malicious code in combination with other flaws. Impact can range from annoyance to complete account compromise, with greater risk when the victim has administrative privileges; in some circumstances, arbitrary code may run on the victim's computer.
| Impact | Scope | Explanation |
|---|---|---|
| Bypass Protection Mechanism, Read Application Data | Access Control, Confidentiality | The most common attack performed with cross-site scripting involves the disclosure of private information stored in user cookies, such as session information. Typically, a malicious user will craft a client-side script, which -- when parsed by a web browser -- performs some activity on behalf of the victim to an attacker-controlled system (such as sending all site cookies to a given E-mail address). This could be especially dangerous to the site if the victim has administrator privileges to manage that site. This script will be loaded and run by each user visiting the web site. Since the site requesting to run the script has access to the cookies in question, the malicious script does also. |
| Execute Unauthorized Code or Commands | Integrity, Confidentiality, Availability | In some circumstances it may be possible to run arbitrary code on a victim's computer when cross-site scripting is combined with other flaws, for example, "drive-by hacking." |
| Execute Unauthorized Code or Commands, Bypass Protection Mechanism, Read Application Data | Confidentiality, Integrity, Availability, Access Control | The consequence of an XSS attack is the same regardless of whether it is stored or reflected. The difference is in how the payload arrives at the server. XSS can cause a variety of problems for the end user that range in severity from an annoyance to complete account compromise. Some cross-site scripting vulnerabilities can be exploited to manipulate or steal cookies, create requests that can be mistaken for those of a valid user, compromise confidential information, or execute malicious code on the end user systems for a variety of nefarious purposes. Other damaging attacks include the disclosure of end user files, installation of Trojan horse programs, redirecting the user to some other page or site, running "Active X" controls (under Microsoft Internet Explorer) from sites that a user perceives as trustworthy, and modifying presentation of content. |
Use context-appropriate output handling. Prefer vetted libraries or frameworks that provide safe output encoding constructs. Determine the required encoding for each output context, including the HTML body, element attributes, URIs, JavaScript sections, and CSS or style properties; HTML entity encoding is appropriate only for the HTML body. Specify an encoding that the downstream component will handle consistently, such as ISO-8859-1, UTF-7, or UTF-8, rather than allowing browsers or other components to guess.
Constrain and validate inputs. Treat all input as malicious and use strict allowlists based on the expected type, length, values, syntax, consistency, and business rules. Validate and cleanse all request data, including hidden fields, cookies, headers, URLs, and other fields not expected to be redisplayed; do not rely exclusively on denylists. Understand every possible input source, and use structured mechanisms that keep data separate from code. Where acceptable filenames or URLs come from a limited known set, map fixed input values such as numeric IDs to those objects and reject other values. Duplicate client-side security checks on the server. For Struts, set the bean filter attribute to true for form-bean data, and in PHP do not use register_globals or an unsafe emulation of it.
Add defense in depth. Set session cookies to HttpOnly where supported, recognizing that this does not prevent all XSS and is not supported by every browser. An application firewall can provide a temporary or additional control when code cannot immediately be fixed, but it may miss input vectors, be bypassed, or reject or modify legitimate requests.
Use automated static analysis, including data-flow analysis, to identify flows from untrusted input to web output. This has only moderate effectiveness because complete accuracy and coverage are not feasible, especially across multiple components. Use black-box testing with the XSS Cheat Sheet or automated test-generation tools to exercise many attack variations; for stored XSS, testing must cover both injection into the data store and later delivery to another user, which may occur after a substantial delay. These approaches are useful but are not complete guarantees.
| Method | Approach | Effectiveness |
|---|---|---|
| Automated Static Analysis | Use automated static analysis tools that target this type of weakness. Many modern techniques use data flow analysis to minimize the number of false positives. This is not a perfect solution, since 100% accuracy and coverage are not feasible, especially when multiple components are involved. | Moderate |
| Black Box | Use the XSS Cheat Sheet [REF-714] or automated test-generation tools to help launch a wide variety of attacks against your web application. The Cheat Sheet contains many subtle XSS variations that are specifically targeted against weak XSS defenses.With Stored XSS, the indirection caused by the data store can make it more difficult to find the problem. The tester must first inject the XSS string into the data store, then find the appropriate application functionality in which the XSS string is sent to other users of the application. These are two distinct steps in which the activation of the XSS can take place minutes, hours, or days after the XSS was originally injected into the data store. | Moderate |
The official record lists the following representative examples, not an exhaustive set: CVE-2024-49038 and CVE-2024-54142 involve XSS in AI-related functionality; CVE-2021-25926 and CVE-2021-25963 involve reflected XSS in Python software; and CVE-2021-1879 describes universal XSS in a mobile operating system. Other examples include XSS reached through a cookie (CVE-2014-8958), crafted HTTP headers such as Referer (CVE-2017-9764, CVE-2014-5198), PATH_INFO (CVE-2008-5770), an email message (CVE-2008-5734), error messages (CVE-2008-4730), wiki pages (CVE-2008-5249), guestbooks (CVE-2006-3568, CVE-2006-3211), and a security product (CVE-2008-0971). Chained examples include CVE-2020-3580, CVE-2008-5080, CVE-2006-4308, CVE-2007-5727, and CVE-2006-3295, where another weakness or protection failure leads to XSS.
Below are representative vulnerabilities related to this CWE, prioritized by severity.
CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.
CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.
Explore CyStack VulnScanen