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 389<br />

Finding and Exploiting SOAP Injection<br />

SOAP injection can be difficult to detect, because supplying XML metacharacters<br />

in a noncrafted way breaks <strong>the</strong> format of <strong>the</strong> SOAP message, often resulting in<br />

an uninformative error message. Never<strong>the</strong>less, <strong>the</strong> following steps can be used<br />

to detect SOAP injection vulnerabilities with a degree of reliability.<br />

HACK STEPS<br />

1. Submit a rogue XML closing tag such as in each parameter in turn.<br />

If no error occurs, your input is probably not being inserted into a SOAP<br />

message, or it is being sanitized in some way.<br />

2. If an error was received, submit instead a valid opening and closing tag<br />

pair, such as . If this causes <strong>the</strong> error to disappear, <strong>the</strong><br />

<strong>application</strong> may be vulnerable.<br />

3. In some situations, data that is inserted into an XML-formatted message<br />

is subsequently read back from its XML form and returned to <strong>the</strong><br />

user. If <strong>the</strong> item you are modifying is being returned in <strong>the</strong> <strong>application</strong>’s<br />

responses, see whe<strong>the</strong>r any XML content you submit is returned in its<br />

identical form or has been normalized in some way. Submit <strong>the</strong> following<br />

two values in turn:<br />

test<br />

test<br />

If you find that ei<strong>the</strong>r item is returned as <strong>the</strong> o<strong>the</strong>r, or simply as test,<br />

you can be confident that your input is being inserted into an XML-based<br />

message.<br />

4. If <strong>the</strong> HTTP request contains several parameters that may be being placed<br />

into a SOAP message, try inserting <strong>the</strong> opening comment character () into<br />

ano<strong>the</strong>r parameter. Then switch <strong>the</strong>se around (because you have no way<br />

of knowing in which order <strong>the</strong> parameters appear). Doing so can have <strong>the</strong><br />

effect of commenting out a portion of <strong>the</strong> server’s SOAP message. This<br />

may cause a change in <strong>the</strong> <strong>application</strong>’s logic or result in a different error<br />

condition that may divulge information.<br />

If SOAP injection is difficult to detect, it can be even harder to exploit. In most<br />

situations, you need to know <strong>the</strong> structure of <strong>the</strong> XML that surrounds your data<br />

to supply crafted input that modifies <strong>the</strong> message without invalidating it. In all<br />

<strong>the</strong> preceding tests, look for any error messages that reveal any details about<br />

<strong>the</strong> SOAP message being processed. If you are lucky, a verbose message will<br />

disclose <strong>the</strong> entire message, enabling you to construct crafted values to exploit<br />

<strong>the</strong> vulnerability. If you are unlucky, you may be restricted to pure guesswork,<br />

which is very unlikely to be successful.

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

Saved successfully!

Ooh no, something went wrong!