Email Spam – How to Properly Filter Outgoing E-mails

emailshared-hostingspam

I have a platform consisting of many web servers doing shared web hosting. These servers run Linux and host tonnes of WordPress, osCommerce, Joomla and other open source website platforms.

Every now and then (read: several times every day) one of these sites get owned, malicious code is injected and the spamming begins.

I have already taken various measures to prevent this, but it seems like these attacks are escalating more and more.

Therefore, my question is to other sysadmins caring for large scale shared hosting platforms: How do you filter (and report?) outgoing e-mail from your web servers? The e-mail that is sent when users in e.g. PHP uses the mail() function or the localhost SMTP server.

Best Answer

You can set up SMTP servers of your own, block SMTP (and submission) traffic outbound from the web servers to anywhere but that SMTP server, and compel your clients to configure that as their outbound MTA. Then, run a spam filter on that SMTP server (spamassassin under postfix might work, though I would disable the RBL filters as they would be useless), and have it drop anything which appears to be spam.

This has a number of severe drawbacks, such as that you might unintentionally silently drop some of your clients' legitimate mail, and that some spam will probably still get through.

Assuming the servers that are spamming are actually supposed to be sending mail at all, the only way you are going to prevent this is by securing the hosts so that they don't get owned. This may prove extremely difficult depending on the exploitability of the versions of the software you're running at each point, and how readily you can patch.

Chances are that if you are getting owned that often, you're being owned by an automated process employing a public exploit. In this case, patching will likely greatly reduce the incidence of this issue.

Related Topic