cross-site scripting

An attack where hostile script is injected into a trusted web page and runs with that page’s access, for example to read data or cookies.

Injected script can act as the user and read anything the page can.

In more detail

HttpOnly cookies limit what injected script can steal, but the real fix is encoding output and validating input so the script never runs. Stored, reflected and DOM-based variants differ only in where the hostile script comes from.

Example

React escapes values it renders, but dangerouslySetInnerHTML and unsafe third-party scripts bypass that.

Related terms

Taught in

References