Web Hacking

Cross-Site Scripting (XSS) Explained

What is it, what types of it are known and more.



Cross-Site Scripting (XSS) is a common web application vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users. In this tutorial, we'll delve into the concept of XSS, its types, and preventive measures to secure web applications.

What is XSS?

XSS occurs when a web application includes untrusted data in a web page without proper validation or escaping, allowing attackers to execute malicious scripts in the context of a user's browser. This can lead to various security risks, including stealing sensitive information, session hijacking, or defacing websites.

Types of XSS

1. Stored XSS

In a stored XSS attack, the malicious script is permanently stored on the target server, often within a database. When a user accesses the compromised page, the script executes.

2. Reflected XSS

Reflected XSS involves injecting a malicious script into a URL, and the server reflects it back to the user in the response. The script then executes in the user's browser.

3. DOM-based XSS

DOM-based XSS occurs when the client-side script manipulates the Document Object Model (DOM) of a web page. The attack takes place on the client side without involving the server.