Intro to XSS

Introduction

As web applications become more advanced and more common, so do web application vulnerabilities. Among the most common types of web application vulnerabilities are Cross-Site Scripting (XSS) vulnerabilities. XSS and XSRF vulnerabilities exploit flaws in user input sanitization to insert and execute JavaScript code on the client side, enabling various attacks.

What is XSS

A web application typically renders HTML received from the server. If it fails to sanitize user input, a malicious user can inject JavaScript code, which is executed when another user views the page.

XSS is executed entirely on the client side and does not directly affect the back-end server. While its impact on the server may be low, its high frequency makes it a medium-risk vulnerability. Medium Risk = Low Impact + High Probability.

Risk Management Matrix: Probability vs. Impact, with strategies like Reduce, Avoid, Accept, and Transfer.
Risk matrix with axes: Probability (low to high) and Impact (low to high), showing strategies: Reduce, Avoid, Accept, Transfer.|450

XSS Attacks

XSS vulnerabilities can be used for:

Modern XSS attacks are sandboxed within the browser and domain but can still lead to advanced exploits. For example, a skilled attacker might use an XSS to trigger a binary exploit (e.g., heap overflow) in the browser.

Notable Examples:

These examples demonstrate that XSS remains a threat even in high-profile web applications.

Types of XSS

There are three main types of XSS vulnerabilities:

Type Description
Stored (Persistent) XSS The most critical type of XSS, which occurs when user input is stored on the back-end database and then displayed upon retrieval (e.g., posts or comments)
Reflected (Non-Persistent) XSS Occurs when user input is displayed on the page after being processed by the backend server, but without being stored (e.g., search result or error message)
DOM-based XSS Another Non-Persistent XSS type that occurs when user input is directly shown in the browser and is completely processed on the client-side, without reaching the back-end server (e.g., through client-side HTTP parameters or anchor tags)