CWE WEAKNESSES / CWE-79
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Base EXPLOIT LIKELIHOOD: HIGH
What it is
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.
Impact
| Access Control, Confidentiality | Bypass Protection Mechanism, Read Application Data |
| Integrity, Confidentiality, Availability | Execute Unauthorized Code or Commands |
| Confidentiality, Integrity, Availability, Access Control | Execute Unauthorized Code or Commands, Bypass Protection Mechanism, Read Application Data |
Mitigations
- [Architecture and Design]Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].Examples of libraries and frameworks that make it easier to generate properly encoded output include Microsoft's Anti-XSS library, the OWASP ESAPI Encoding module, and Apache Wicket.
- [Implementation, Architecture and Design]Understand the context in which your data will be used and the encoding that will be expected. This is especially important when transmitting data between different components, or when generating outputs that can contain multiple encodings at the same time, such as web pages or multi-part mail messages. Study all expected communication protocols and data representations to determine the required
- [Architecture and Design, Implementation] Understand all the potential areas where untrusted inputs can enter your software: parameters or arguments, cookies, anything read from the network, environment variables, reverse DNS lookups, query results, request headers, URL components, e-mail, files, filenames, databases, and any external systems that provide data to the application. Remember that such inputs may be obtained indirectly throug
- [Architecture and Design] For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
- [Architecture and Design] If available, use structured mechanisms that automatically enforce the separation between data and code. These mechanisms may be able to provide the relevant quoting, encoding, and validation automatically, instead of relying on the developer to provide this capability at every point where output is generated.
- [Implementation]Use and specify an output encoding that can be handled by the downstream component that is reading the output. Common encodings include ISO-8859-1, UTF-7, and UTF-8. When an encoding is not specified, a downstream component may choose a different encoding, either by assuming a default encoding or automatically inferring which encoding is being used, which can be erroneous. When the encodings are
- [Implementation] With Struts, write all data from form beans with the bean's filter attribute set to true.
- [Implementation] To help mitigate XSS attacks against the user's session cookie, set the session cookie to be HttpOnly. In browsers that support the HttpOnly feature (such as more recent versions of Internet Explorer and Firefox), this attribute can prevent the user's session cookie from being accessible to malicious client-side scripts that use document.cookie. This is not a complete solution, since HttpOnly is n
Real-world CVE examples
- CVE-2024-49038 — XSS in AI assistant
- CVE-2024-54142 — Plugin that enables AI features allows input with html entities, leading to XSS
- CVE-2021-25926 — Python Library Manager did not sufficiently neutralize a user-supplied search term, allowing reflected XSS.
- CVE-2021-25963 — Python-based e-commerce platform did not escape returned content on error pages, allowing for reflected Cross-Site Scripting attacks.
- CVE-2021-1879 — Universal XSS in mobile operating system, as exploited in the wild per CISA KEV.
- CVE-2020-3580 — Chain: improper input validation (CWE-20) in firewall product leads to XSS (CWE-79), as exploited in the wild per CISA KEV.
- CVE-2014-8958 — Admin GUI allows XSS through cookie.
- CVE-2017-9764 — Web stats program allows XSS through crafted HTTP header.
- CVE-2014-5198 — Web log analysis product allows XSS through crafted HTTP Referer header.
- CVE-2008-5080 — Chain: protection mechanism failure allows XSS
- CVE-2006-4308 — Chain: incomplete denylist (CWE-184) only checks "javascript:" tag, allowing XSS (CWE-79) using other tags
- CVE-2007-5727 — Chain: incomplete denylist (CWE-184) only removes SCRIPT tags, enabling XSS (CWE-79)
Related weaknesses
Test & detect
Browse all common weaknesses, check related exploited CVEs, or map to ATT&CK techniques.
Source: MITRE CWE. View on cwe.mitre.org →