166 terms · 75/46/45
Threat № 040 · class: applications

Cross-Site Scripting

Cross-site scripting, better known as XSS, arises when a web application allows somebody else's script to be displayed and executed in the user's browser. The attacker does not have to break into the web server. It is enough for their code to end up in a page the victim opens as though it were entirely legitimate.

Term

description · examples · notes

Cross-site scripting, better known as XSS, arises when a web application allows somebody else's script to be displayed and executed in the user's browser. The attacker does not have to break into the web server. It is enough for their code to end up in a page the victim opens as though it were entirely legitimate.

Description

The browser then executes the script in the context of a site the user trusts. That means the script can see part of the page content, change what is displayed, send requests, steal tokens that are not well protected, or slip the user a fake login form. To the user everything still looks like the same familiar site.

XSS is often the result of a poor attitude to user input. A comment, a search, a profile name, a parameter in a link or a part of the DOM become the places through which an attacker injects malicious code. If the web application does not handle that input properly before display, the line between content and program code slowly disappears.

Examples

  • The attacker injects a script into a comment on a forum. Every user who opens the thread unknowingly executes that code in their own browser, on their own machine.
  • The victim is sent a link with a specially prepared search parameter. The page returns the result together with a script that executes immediately.
  • DOM XSS changes the page display and inserts a fake login form that looks like part of the legitimate application.

Notes

  • XSS is not merely a cosmetic matter. Carried out in the right place, it can cause session theft, account takeover or a covert way into a business application.
  • Protection does not come down to deleting a few dangerous characters. It takes proper output encoding, a Content Security Policy, HttpOnly cookies and discipline in handling user input.

Mentioned in the news

Composite
Wikipedia

Techniques

carried out with 3

Techniques used to carry it out. Select one to open its page.

Defenses

countered by 3

How it is defended against. Select one to open its page.