Recently, the webserver on my linode was hacked to send 70,000 ebay 'fishing' emails.
I became aware of this in a very short time as the bounces for invalid addresses on the list the attacker used went back to my www-data, which is aliased to root, which is aliased to my account. Thus, I got about 25,000 bounce emails in my personal account, which caused pine to die horribly by memory exaustion when it tried to open my inbox.
Since then, I've added many new security measures to my webserver designed to stop this sort of thing from happening again.
1) PHP reconfigured (php4)
* I've used safe_mode to disable mail(), and exec() in php <--- though I might turn this back off in a few days, as it breaks a lot of functionality in user websites.
* I've set harsh process limits (e.g. max runtime for scripts = 30s) on php
2) Httpd reconfigured (apache)
* I've disallowed SSI on user webpages (I did have IncludesNoExec)
* I've set apache to log ALL access to the webserver
3) MTA reconfigured (exim)
* I've reconfigured my MTA not to count the webserver as 'trusted'.... so all outgoing emails sent via the webserver have "myhost WEBSERVER" tagged as their "From".... thus making fishing scams pointless as they would be easily detected.
I'm currently using debian linux. I'm shortly moving to an OpenBSD dedicated server, where additionally, I will have :
1) a fully chrooted apache
2) mod_security loaded
3) process accounting
4) fewer shell users
Does anyone have any other tips for how I can prevent people taking advantage of my webserver like this?
The provisions :
1) I still have to give relatively untrusted people shell access. Unfortunately, that's the nature of my business.
2) I still have to allow them to have websites with userdir, php, and mysql.
3) I should, if at all possible, still allow the sending of mail via www-data.
I've tried looking in my apache's logs...... I can't find anything out of the ordinary, and I've tried looking in my MTA logs, it just identifies all the mail as coming from www-data.
What I'd really like is some kind of script so that any mail sent via www-data is tagged with the location of the file or program which caused that mail to be sent, so for example, I could look at any future fishing emails and see that they were tagged as :
SENT : via www-data : mail() invoked at /home/naughtyuser/public_html/muahaha.php like 24
Anyone know if this is possible? I'm really angry at this guy for spamming through my webserver. I've not been able to track him down, even resorting to rather extreme measures like searching for his scripts via
grep -ri 'ebay' /home/* .
Any suggestions for how to make such spamming from my webserver more difficult or impossible in future, especially those that mean I would end up with reliable logs as to who is doing it, would be much appreciated.