xss:xss_attacks
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
xss:xss_attacks [2016/10/10 01:07] – peter | xss:xss_attacks [2020/04/15 08:46] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== XSS - XSS Attacks ====== | ||
- | |||
- | ===== Actors in an XSS attack ===== | ||
- | |||
- | Before we describe in detail how an XSS attack works, we need to define the actors involved in an XSS attack. | ||
- | |||
- | **The website** serves HTML pages to users who request them. In our examples, it is located at http:// | ||
- | |||
- | * The website' | ||
- | |||
- | **The victim** is a normal user of the website who requests pages from it using his browser. | ||
- | |||
- | **The attacker** is a malicious user of the website who intends to launch an attack on the victim by exploiting an XSS vulnerability in the website. | ||
- | |||
- | * The attacker' | ||
- | |||
- | |||
- | ===== An example attack scenario ===== | ||
- | |||
- | In this example, we will assume that the attacker' | ||
- | |||
- | <code html> | ||
- | < | ||
- | window.location=' | ||
- | </ | ||
- | </ | ||
- | |||
- | This script navigates the user's browser to a different URL, triggering an HTTP request to the attacker' | ||
- | |||
- | From now on, the HTML code above will be referred to as the malicious string or the malicious script. | ||
- | |||
- | How the example attack works | ||
- | |||
- | The diagram below illustrates how this example attack can be performed by an attacker: | ||
- | |||
- | {{: | ||
- | |||
- | 1. The attacker uses one of the website' | ||
- | |||
- | 2. The victim requests a page from the website. | ||
- | |||
- | 3. The website includes the malicious string from the database in the response and sends it to the victim. | ||
- | |||
- | 4. The victim' | ||
- | |||
- | |||
- | ===== Types of XSS ===== | ||
- | |||
- | While the goal of an XSS attack is always to execute malicious JavaScript in the victim' | ||
- | |||
- | * Persistent XSS, where the malicious string originates from the website' | ||
- | * Reflected XSS, where the malicious string originates from the victim' | ||
- | * DOM-based XSS, where the vulnerability is in the client-side code rather than the server-side code. | ||
- | |||
- | The previous example illustrated a persistent XSS attack. | ||
- | Reflected XSS | ||
- | |||
- | In a reflected XSS attack, the malicious string is part of the victim' | ||
- | |||
- | {{: | ||
- | |||
- | 1. The attacker crafts a URL containing a malicious string and sends it to the victim. | ||
- | |||
- | 2. The victim is tricked by the attacker into requesting the URL from the website. | ||
- | |||
- | 3. The website includes the malicious string from the URL in the response. | ||
- | |||
- | 4. The victim' | ||
- | |||
- | |||
- | ==== How can reflected XSS succeed? ==== | ||
- | |||
- | At first, reflected XSS might seem harmless because it requires the victim himself to actually send a request containing a malicious string. Since nobody would willingly attack himself, there seems to be no way of actually performing the attack. | ||
- | |||
- | As it turns out, there are at least two common ways of causing a victim to launch a reflected XSS attack against himself: | ||
- | |||
- | * If the user targets a specific individual, the attacker can send the malicious URL to the victim (using e-mail or instant messaging, for example) and trick him into visiting it. | ||
- | |||
- | * If the user targets a large group of people, the attacker can publish a link to the malicious URL (on his own website or on a social network, for example) and wait for visitors to click it. | ||
- | |||
- | These two methods are similar, and both can be more successful with the use of a URL shortening service, which masks the malicious string from users who might otherwise identify it. | ||
- | |||
xss/xss_attacks.1476061646.txt.gz · Last modified: 2020/07/15 09:30 (external edit)