19.09.2017 Views

the-web-application-hackers-handbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 13 n Attacking Users: O<strong>the</strong>r Techniques 563<br />

n The non-HTTP service must echo part of <strong>the</strong> request contents in its response,<br />

such as in an error message.<br />

n The browser must tolerate responses that do not contain valid HTTP<br />

headers, and in this situation must process a portion of <strong>the</strong> response as<br />

HTML if that is what it contains. This is in fact how all current browsers<br />

behave when suitable non-HTTP responses are received, probably for<br />

backward-compatibility purposes.<br />

n The browser must ignore <strong>the</strong> port number when segregating cross-origin<br />

access to cookies. Current browsers are indeed port-agnostic in <strong>the</strong>ir<br />

handling of cookies.<br />

Given <strong>the</strong>se conditions, an attacker can construct an XSS attack targeting <strong>the</strong><br />

non-HTTP service. The attack involves sending a crafted request, in <strong>the</strong> URL<br />

or message body, in <strong>the</strong> normal way. Script code contained in <strong>the</strong> requests is<br />

echoed and executes in <strong>the</strong> user’s browser. This code can read <strong>the</strong> user’s cookies<br />

for <strong>the</strong> domain on which <strong>the</strong> non-HTTP service resides, and transmit <strong>the</strong>se<br />

to <strong>the</strong> attacker.<br />

Exploiting Browser Bugs<br />

If bugs exist within <strong>the</strong> user’s browser software or any installed extensions, an<br />

attacker may be able to exploit <strong>the</strong>se via malicious JavaScript or HTML. In some<br />

cases, bugs within extensions such as <strong>the</strong> Java VM have enabled attackers to<br />

perform two-way binary communication with non-HTTP services on <strong>the</strong> local<br />

computer or elsewhere. This enables <strong>the</strong> attacker to exploit vulnerabilities that<br />

exist within o<strong>the</strong>r services identified via port scanning. Many software products<br />

(including non-browser-based products) install ActiveX controls that may<br />

contain vulnerabilities.<br />

DNS Rebinding<br />

DNS rebinding is a technique that can be used to perform a partial breach of<br />

same-origin restrictions in some situations, enabling a malicious <strong>web</strong>site to<br />

interact with a different domain. The possibility of this attack arises because <strong>the</strong><br />

segregations in <strong>the</strong> same-origin policy are based primarily on domain names,<br />

whereas <strong>the</strong> ultimate delivery of HTTP requests involves converting domain<br />

names into IP addresses.<br />

At a high level, <strong>the</strong> attack works as follows:<br />

n The user visits a malicious <strong>web</strong> page on <strong>the</strong> attacker’s domain. To retrieve<br />

this page, <strong>the</strong> user’s browser resolves <strong>the</strong> attacker’s domain name to <strong>the</strong><br />

attacker’s IP address.<br />

n The attacker’s <strong>web</strong> page makes Ajax requests back to <strong>the</strong> attacker’s domain,<br />

which is allowed by <strong>the</strong> same-origin policy. The attacker uses DNS rebinding

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!