What Is XSS Attack | Cybersecurity

Demystifying What is an XSS Attack
The process of an XSS attack begins with the attacker identifying a vulnerability within a web application that either does not properly sanitise user input or incorrectly handles data within the Document Object Model (DOM).

The attacker then creates a malicious script to exploit this vulnerability. When the script is executed, it can perform actions on behalf of the user, manipulate web content or steal information, all without the user's consent or awareness.

Exploring The Types Of XSS Attacks
Reflected XSS:Reflected XSS

This type occurs when an attacker sends a crafted URL containing malicious script to a user. When the user clicks on the link, the web application receives the malicious data as input and reflects it back in the response. The browser then executes the script because it appears to be coming from a trusted source. Reflected XSS requires the victim to actively click on a malicious link and is only effective for the duration of a single session.

Stored XSS: Unlike reflected XSS, stored XSS involves the malicious script being saved on the web server, such as in a comment, forum post or in user-generated content. This script is then served to every user who accesses the stored content. Stored XSS is particularly dangerous because it can affect many users and does not require the victim to take any action like clicking on a link.

DOM-based XSS:DOM-based XSS

In this type, the vulnerability is in the client-side code rather than the server-side or the input itself. The attack occurs when the webpage’s JavaScript takes data from user inputs (like URL parameters) and dynamically writes it to the DOM without proper sanitisation. The user’s browser then executes the full page including the malicious script that has been added to the DOM. This type of XSS attack occurs entirely on the client side.