Cross-Site Scripting (XSS)

CWE: 79
CVE: 2019-3826

What is the attack?
XSS is an attack where a malicious script is injected into any 'input' field on a trusted website such that it is rendered hampering user experience. There are three main types of XSS attacks. They are as follows:

  1. Reflected XSS:
    When an XSS script is injected such that it will render on the same web-instance in the form of a pop-up or message on the screen, it is known as a Reflected XSS vulnerability. This vulnerability is relatively less harmful.
  1. Stored XSS:
    When an XSS script is injected such that it will be stored on the server and is rendered only when it is fetched from the server by a user, it is known as stored XSS vulnerability. This vulnerability is relatively more harmful because the script has the potential to inject malicious scripts in the user's machine or steal cookies from user's machine.
  2. DOM (Document Object Model) based XSS:
    In this type of attack, XSS payload is injected in the DOM fields or "select" fields on the website, usually found in edit profile forms. Such attacks have the potential to alter important data in a user's account and affect user experience.

What is the impact of this attack?
If an attacker is successful in injecting an XSS Script, he can ?

  1. Hijack user accounts by stealing session cookies
  2. Steal user credentials
  3. Steal, manipulate or delete sensitive data
  4. Initiate downloading of malicious files on user's machine
  5. Impact user experience

How to prevent this attack?
Following measures can be taken to prevent XSS attacks ?

  1. Sanitization of data on both client and server side.
  2. Using a strong firewall
  3. Encrypting the data