xss:about_xss
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
xss:about_xss [2016/10/10 00:46] – peter | xss:about_xss [2020/04/15 08:44] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== XSS - About XSS ====== | ||
- | |||
- | ===== What is XSS? ===== | ||
- | |||
- | Cross-site scripting (XSS) is a code injection attack that allows an attacker to execute malicious JavaScript in another user's browser. | ||
- | |||
- | The attacker does not directly target his victim. | ||
- | |||
- | |||
- | ===== How the malicious JavaScript is injected ===== | ||
- | |||
- | The only way for the attacker to run his malicious JavaScript in the victim' | ||
- | |||
- | In the example below, a simple server-side script is used to display the latest comment on a website: | ||
- | |||
- | <code html> | ||
- | print "< | ||
- | print " | ||
- | print database.latestComment | ||
- | print "</ | ||
- | </ | ||
- | |||
- | The script assumes that a comment consists only of text. However, since the user input is included directly, an attacker could submit this comment: <color red> | ||
- | |||
- | <code html> | ||
- | < | ||
- | Latest comment: | ||
- | < | ||
- | </ | ||
- | </ | ||
- | |||
- | When the user's browser loads the page, it will execute whatever JavaScript code is contained inside the **< | ||
- | |||
- | |||
- | ===== What is malicious JavaScript? ===== | ||
- | |||
- | At first, the ability to execute JavaScript in the victim' | ||
- | |||
- | However, the possibility of JavaScript being malicious becomes more clear when you consider the following facts: | ||
- | |||
- | * JavaScript has access to some of the user's sensitive information, | ||
- | * JavaScript can send HTTP requests with arbitrary content to arbitrary destinations by using XMLHttpRequest and other mechanisms. | ||
- | * JavaScript can make arbitrary modifications to the HTML of the current page by using DOM manipulation methods. | ||
- | |||
- | These facts combined can cause very serious security breaches, as we will explain next. | ||
- | |||
- | ===== The consequences of malicious JavaScript ===== | ||
- | |||
- | Among many other things, the ability to execute arbitrary JavaScript in another user's browser allows an attacker to perform the following types of attacks: | ||
- | |||
- | * **Cookie theft**\\ The attacker can access the victim' | ||
- | |||
- | * **Keylogging**\\ The attacker can register a keyboard event listener using addEventListener and then send all of the user's keystrokes to his own server, potentially recording sensitive information such as passwords and credit card numbers. | ||
- | |||
- | * **Phishing**\\ The attacker can insert a fake login form into the page using DOM manipulation, | ||
- | |||
- | Although these attacks differ significantly, | ||
- | |||
- | This fact highlights a key issue: | ||
- | |||
- | If an attacker can use your website to execute arbitrary JavaScript in another user's browser, the security of your website and its users has been compromised. | ||
- | |||
- | To emphasize this point, some examples in this tutorial will leave out the details of a malicious script by only showing < | ||
- | |||
xss/about_xss.1476060360.txt.gz · Last modified: 2020/07/15 09:30 (external edit)