WhatsApp
    Glosario de ciberseguridad

    What is a Cross-Site Scripting (XSS) attack?

    Cross-Site Scripting (XSS) is a web vulnerability that lets an attacker inject malicious JavaScript into a trusted page. When other users visit it, their browsers run the attacker's code with the same permissions as the legitimate site.

    XSS types

    • Reflected: payload travels in the URL and is echoed unescaped.
    • Stored (persistent): payload is saved (comments, profiles) and hits every visitor.
    • DOM-based: manipulation happens entirely client-side.

    What an attacker can do with XSS

    • Steal session cookies and impersonate the victim.
    • Capture credentials with fake forms on top of the real page.
    • Redirect to malicious sites or act on behalf of the user.
    • Distribute malware from the browser.

    How to prevent XSS

    • Escape and encode every output per context (HTML, attribute, JS, URL).
    • Validate input server-side with strict allow-lists.
    • Apply Content Security Policy (CSP).
    • Mark session cookies as HttpOnly and Secure.
    • Use frameworks that escape by default (React, Vue).

    Términos relacionados