SecSIGSecurity Special Interest Group of US MensaCuriosity. Perspective. Security.

Research Library · Idea

Cross-site scripting

Cross-site scripting (XSS) occurs when a web application lets untrusted content run as code in a page served under the application's origin. The browser gives that code the privileges available to scripts on the page. Depending on the application and the user's permissions, it can read information visible to the user or perform actions in the user's session. MITRE tracks the weakness as CWE-79. 1

Reflected XSS involves request data returned in the response. Stored XSS involves data the application saves and subsequently displays, so one unsafe rendering path can affect multiple users. In DOM-based XSS, the unsafe interpretation happens in the browser as client-side code updates the page. Reviewing server templates and client-side rendering together helps find where those paths meet. 12

OWASP recommends rendering untrusted values as text through safe interfaces or using output encoding matched to the destination context. Applications that intentionally accept rich HTML need a maintained sanitizer. Framework escaping covers supported rendering paths, so review any direct HTML insertion separately. A Content Security Policy adds a layer of protection while those rendering controls address the underlying flaw. 2

Source · CWE-79: Cross-site Scripting (opens in a new tab) · MITRE

References

  1. CWE-79: Cross-site Scripting (opens in a new tab) · MITRE ↩ ↩
  2. Cross Site Scripting Prevention Cheat Sheet (opens in a new tab) · OWASP ↩ ↩

In the news

See what connects to it on the map of ideas →

See also