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 10 n Attacking Back-End Components 387<br />

Because XML is an interpreted language, SOAP is potentially vulnerable to<br />

code injection in a similar way as <strong>the</strong> o<strong>the</strong>r examples already described. XML<br />

elements are represented syntactically, using <strong>the</strong> metacharacters , and /. If<br />

user-supplied data containing <strong>the</strong>se characters is inserted directly into a SOAP<br />

message, an attacker may be able to interfere with <strong>the</strong> message’s structure and<br />

<strong>the</strong>refore interfere with <strong>the</strong> <strong>application</strong>’s logic or cause o<strong>the</strong>r undesirable effects.<br />

Consider a banking <strong>application</strong> in which a user initiates a funds transfer<br />

using an HTTP request like <strong>the</strong> following:<br />

POST /bank/27/Default.aspx HTTP/1.0<br />

Host: mdsec.net<br />

Content-Length: 65<br />

FromAccount=18281008&Amount=1430&ToAccount=08447656&Submit=Submit<br />

In <strong>the</strong> course of processing this request, <strong>the</strong> following SOAP message is sent<br />

between two of <strong>the</strong> <strong>application</strong>’s back-end components:<br />

<br />

<br />

<br />

<br />

18281008<br />

1430<br />

False<br />

08447656<br />

<br />

<br />

<br />

<br />

Note how <strong>the</strong> XML elements in <strong>the</strong> message correspond to <strong>the</strong> parameters<br />

in <strong>the</strong> HTTP request, and also <strong>the</strong> addition of <strong>the</strong> ClearedFunds element. At<br />

this point in <strong>the</strong> <strong>application</strong>’s logic, it has determined that insufficient funds<br />

are available to perform <strong>the</strong> requested transfer and has set <strong>the</strong> value of this<br />

element to False. As a result, <strong>the</strong> component that receives <strong>the</strong> SOAP message<br />

does not act on it.<br />

In this situation, <strong>the</strong>re are various ways in which you could seek to inject<br />

into <strong>the</strong> SOAP message and <strong>the</strong>refore interfere with <strong>the</strong> <strong>application</strong>’s logic. For<br />

example, submitting <strong>the</strong> following request causes an additional ClearedFunds<br />

element to be inserted into <strong>the</strong> message before <strong>the</strong> original element (while<br />

preserving <strong>the</strong> SQL’s syntactic validity). If <strong>the</strong> <strong>application</strong> processes <strong>the</strong> first<br />

ClearedFunds element it encounters, you may succeed in performing a transfer<br />

when no funds are available:<br />

POST /bank/27/Default.aspx HTTP/1.0<br />

Host: mdsec.net

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

Saved successfully!

Ooh no, something went wrong!