3 ms·
You can prevent this kind of thing, or at least make it easier to keep track of. Add these rules to your iptables firewall: -A OUTPUT -m owner --uid-owner
by ars 12y ago
You can prevent this kind of thing, or at least make it easier to keep track of.
Add these rules to your iptables firewall:
-A OUTPUT -m owner --uid-owner Debian-exim -p tcp --dport 25 -j ACCEPT
-A OUTPUT -p tcp -d 127.0.0.1 --dport 25 -j ACCEPT
-A OUTPUT -p tcp --dport 25 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp --dport 25 -j LOG --log-level debug --log-uid --log-prefix "smtp_block "
-A OUTPUT -p tcp --dport 25 -j REJECT
This blocks anyone except exim from sending email. (Note these rules are not tested with IPv6.)
Then, keep a log of every outgoing email, by adding in /etc/exim/exim4.conf.template:
After:
begin routers
Add:
traffic_tap:
unseen
no_expn
no_verify
transport = local_copy
driver = accept
After:
begin transports
Add:
local_copy:
driver = appendfile
delivery_date_add
envelope_to_add
return_path_add
maildir_format = true
create_directory = true
directory = /var/log/mail_archive/$tod_logfile/
Create /var/log/mail_archive with write access for Debian-exim
Obviously these rules are for exim on Debian, but you can use the ideas for other systems.
- crypt1d 12y agoNot that there is anything particularly wrong with this, but I find it silly that one should make such customization on their box just to prevent _one_ potential malware hazard. There are hundred other ways that an infected machine can be abused, so IMHO prevention should be done based on attack vectors - that is stopping the machine from getting infected in the first place.
- voidlogic 12y ago>Not that there is anything particularly wrong with this, but I find it silly that one should make such customization on their box just to prevent _one_ potential malware hazard. I generally drop all inbound and outbound by default and open the ports in the direction (out vs in) I need on the box. Why not take it one step farther and tie each opening rule to the process/user that actually needs it? That seems like an awesome idea.
- crypt1d 12y agoIf this is the only box that you will ever maintain, then sure, knock yourself out. The problem shows up once you start maintaining hundreds of boxes, because you have an overly complex security setup that does not bring any substantial benefit to the table. It becomes just another thing you have to think about every time you redesign your environment, install new tools, etc. You are essentially sacrificing simplicity for a false sense of security.
- rwmj 12y agoIt's a another example of enumerating badness: http://www.ranum.com/security/computer_security/editorials/dumb/ http://www.ranum.com/security/computer_security/editorials/d... which is prevented by only permitting traffic that is supposed to be on your network / going through your NIC.
- ars 12y agoIt's not to prevent just one malware. Virtually all malware (on servers) these days has just one goal: send spam. Plus outbound spam has a very visible and detrimental impact on your reputation so warrants extra defense.
- verroq 12y agoSpam AND DDOS.
- colinbartlett 12y agoIs mining Bitcoin on owned boxes not a thing anymore? I guess because the difficulty has risen too high for ordinary CPUs?