CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
VariantLikelihood of exploit: High
The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.
Consequences
- Confidentiality, Integrity, Availability: Read Application Data, Execute Unauthorized Code or Commands
How to prevent it
- Implementation: Carefully check each input parameter against a rigorous positive specification (allowlist) defining the specific characters and format allowed. All input should be neutralized, not just parameters that the user is supposed to specify, but all data in the request, including hidden fields, cookies, headers, the URL itself, and so forth. A common mistake that leads to continuing XSS vulnerabilities is to validate only fields that are expected to be redisplayed by the site. We often encounter data from the request that is reflected by the application server or the application that the development team did not anticipate. Also, a field that is not currently reflected may be used by a future developer. Therefore, validating ALL parts of the HTTP request is recommended.
- 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 inconsistent, the downstream component might treat some character or byte sequences as special, even if they are not special in the original encoding. Attackers might then be able to exploit this discrepancy and conduct injection attacks; they even might be able to bypass protection mechanisms that assume the original encoding is also being used by the downstream component. The problem of inconsistent output encodings often arises in web pages. If an encoding is not specified in an HTTP header, web browsers often guess about which encoding is being used. This can open up the browser to subtle XSS attacks.
- 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 not supported by all browsers. More importantly, XmlHttpRequest and other powerful browser technologies provide read access to HTTP headers, including the Set-Cookie header in which the HttpOnly flag is set.
Recent advisories
- GHSA-9jrq-w75r-8gcw — Vite: Cross origin script execution through Vite custom middleware
- GHSA-jh5r-qr3c-85q8 — Laravel: XSS in Debug Page Information
- GHSA-r5xw-gcgw-hwp5 — YesWiki Vulnerable to Reflected XSS via Unescaped `id` Parameter in Bazar Widget HTML Attributes
- GHSA-35f3-pg38-486f — YesWiki Vulnerable to Reflected XSS via Unescaped Archived-Revision `time` Parameter in `handlers/page/show.php`
- GHSA-3w28-36p9-w929 — Gogs's Unauthenticated Jupyter Notebook (ipynb) Sanitizer allows arbitrary data: URIs leading to XSS
- GHSA-p6qx-ghxm-389h — OctoPrint has XSS in its Suppressed Command Notifications
- GHSA-6vxv-wg6j-5qwp — Gogs: XSS in .ipynb files renderer due to outdated notebookjs
- GHSA-8hv8-536x-4wqp — Astro: Reflected XSS via unescaped slot name
- GHSA-5cmv-3rc4-7279 — Weblate vulnerable to XSS via crafted Markdown
- GHSA-6wpp-88cp-7q68 — PhpSpreadsheet has XSS via NumberFormat @ Text Substitution in HTML Writer
- GHSA-w4fj-87j5-f25c — XWiki has Reflected Cross-Site Scripting (XSS) in page history compare
- GHSA-cpj3-3r2f-xj59 — OpenBao has Reflected XSS in its OIDC authentication error message
- GHSA-2p9h-rqjw-gm92 — n8n Vulnerable to Stored XSS via Various Nodes
- GHSA-4qgr-4h56-8895 — Vikunja has Reflected HTML Injection via filter Parameter in its Projects Module
- GHSA-m4g2-2q66-vc9v — Vikunja Vulnerable to XSS Via Task Preview
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor