Toutes les vulnérabilités
HIGHAppSecexploited in the wild

APPSEC-XSS

Web app · Cross-Site Scripting

Résumé

Cross-site scripting occurs when an application places untrusted input into HTML, JavaScript, or DOM contexts without context-aware encoding, so the browser parses attacker-controlled characters as executable script rather than inert text; the three forms are stored (payload persisted server-side and served to other users), reflected (payload echoed back in the immediate response), and DOM-based (client-side JavaScript writes input into a sink like innerHTML or document.write). Running in the victim's session, the script can steal cookies, forge requests, or rewrite the page. It maps to OWASP A03:2021 Injection (CWE-79). The October 4, 2005 Samy worm exploited a stored XSS flaw in MySpace profiles, and within 20 hours over one million users had run its self-propagating payload, the fastest-spreading worm at the time. The high-impact modern form is Magecart card skimming, as in the 2018 British Airways breach where injected payment-page JavaScript skimmed around 400,000 customers' card details and led to a GBP 20 million ICO fine.

Comment l’éviter dans votre code

  • Apply context-aware output encoding (HTML, attribute, JS, URL) at every point untrusted data enters a page.
  • Prefer frameworks with auto-escaping (React, Angular, Vue) and avoid innerHTML, document.write, and dangerouslySetInnerHTML.
  • Deploy a strict Content-Security-Policy with nonces/hashes to block inline and injected scripts.
  • Set HttpOnly and Secure flags on session cookies to limit theft via script.
  • Sanitize rich HTML server-side with a vetted allowlist library such as DOMPurify.

Références

Vulnérabilités liées

Tout AppSec →