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.

374 Chapter 10 n Attacking Back-End Components<br />

Figure 10-5: A successful path traversal attack<br />

NOTE Virtually all filesystems tolerate redundant traversal sequences that<br />

appear to try to move above <strong>the</strong> root of <strong>the</strong> filesystem. Hence, it is usually<br />

advisable to submit a large number of traversal sequences when probing for<br />

a flaw, as in <strong>the</strong> examples given here. It is possible that <strong>the</strong> starting directory<br />

to which your data is appended lies deep within <strong>the</strong> filesystem, so using an<br />

excessive number of sequences helps avoid false negatives.<br />

Also, <strong>the</strong> Windows platform tolerates both forward slashes and backslashes<br />

as directory separators, whereas UNIX-based platforms tolerate only <strong>the</strong> forward<br />

slash. Fur<strong>the</strong>rmore, some <strong>web</strong> <strong>application</strong>s filter one version but not<br />

<strong>the</strong> o<strong>the</strong>r. Even if you are certain that <strong>the</strong> <strong>web</strong> server is running a UNIX-based<br />

operating system, <strong>the</strong> <strong>application</strong> may still be calling out to a Windows-based<br />

back-end component. Because of this, it is always advisable to try both versions<br />

when probing for traversal flaws.<br />

Circumventing Obstacles to Traversal Attacks<br />

If your initial attempts to perform a traversal attack (as just described) are<br />

unsuccessful, this does not mean that <strong>the</strong> <strong>application</strong> is not vulnerable. Many<br />

<strong>application</strong> developers are aware of path traversal vulnerabilities and implement<br />

various kinds of input validation checks in an attempt to prevent <strong>the</strong>m. However,<br />

those defenses are often flawed and can be bypassed by a skilled attacker.<br />

The first type of input filter commonly encountered involves checking whe<strong>the</strong>r<br />

<strong>the</strong> filename parameter contains any path traversal sequences. If it does, <strong>the</strong><br />

filter ei<strong>the</strong>r rejects <strong>the</strong> request or attempts to sanitize <strong>the</strong> input to remove <strong>the</strong><br />

sequences. This type of filter is often vulnerable to various attacks that use alternative<br />

encodings and o<strong>the</strong>r tricks to defeat <strong>the</strong> filter. These attacks all exploit<br />

<strong>the</strong> type of canonicalization problems faced by input validation mechanisms,<br />

as described in Chapter 2.

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

Saved successfully!

Ooh no, something went wrong!