19.09.2017 Views

the-web-application-hackers-handbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Figure 10-7: An e-mail header injection attack<br />

This causes <strong>the</strong> mail() command to generate <strong>the</strong> following message:<br />

To: admin@wahh-app.com<br />

From: marcus@wahh-mail.com<br />

Bcc: all@wahh-o<strong>the</strong>rcompany.com<br />

Subject: Site problem<br />

Confirm Order page doesn’t load<br />

SMTP Command Injection<br />

In o<strong>the</strong>r cases, <strong>the</strong> <strong>application</strong> may perform <strong>the</strong> SMTP conversation itself, or it<br />

may pass user-supplied input to a different component to do this. In this situation,<br />

it may be possible to inject arbitrary SMTP commands directly into this<br />

conversation, potentially taking full control of <strong>the</strong> messages being generated<br />

by <strong>the</strong> <strong>application</strong>.<br />

For example, consider an <strong>application</strong> that uses requests of <strong>the</strong> following form<br />

to submit site feedback:<br />

POST feedback.php HTTP/1.1<br />

Host: wahh-app.com<br />

Content-Length: 56<br />

From=daf@wahh-mail.com&Subject=Site+feedback&Message=foo<br />

This causes <strong>the</strong> <strong>web</strong> <strong>application</strong> to perform an SMTP conversation with <strong>the</strong><br />

following commands:<br />

MAIL FROM: daf@wahh-mail.com<br />

RCPT TO: feedback@wahh-app.com<br />

DATA<br />

From: daf@wahh-mail.com<br />

To: feedback@wahh-app.com<br />

Subject: Site feedback<br />

foo<br />

.

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

Saved successfully!

Ooh no, something went wrong!