alias5000
Anmeldungsdatum: 26. Dezember 2006
Beiträge: 51
|
Hi!
Ich habe gestern entdeckt, dass mein debian server als Spam-Server missbraucht worden ist. Nachdem ich erstmal sicher gestellt habe, dass den Spammern der Zugang zu meinem Server verweigert wird, möchte ich jetzt aber herausfinden, warum es den Spammern überhaupt möglich war, meinen Server als relaz zu missbrauchen. Dabei ist mir nicht ganz klar, wie ich das Szenario selbst reproduzieren kann.
Der Log-Eintrag einer solchen Spam-Email sah immer so aus (natürlich hab ich kräftig <anonymisiert>):
1
2
3
4
5
6
7
8
9
10
11
12 | Apr 4 15:55:43 v01 postfix/smtpd[6453]: connect from <some-ip>.dynamic-ip.hinet.net[<some-ip>]
Apr 4 15:55:44 v01 postfix/smtpd[6453]: 279741BE050: client=<some-ip>.dynamic-ip.hinet.net[<some-ip>]
Apr 4 15:55:48 v01 postfix/cleanup[6457]: 279741BE050: message-id=<JAUBXKGJENBGNKUDQGFTC@163.com>
Apr 4 15:55:49 v01 postfix/qmgr[18744]: 279741BE050: from=<<randomsender>@163.com>, size=7041, nrcpt=13 (queue active)
Apr 4 15:55:50 v01 postfix/smtpd[6453]: DFF851BE055: client=<some-ip>.dynamic-ip.hinet.net[<some-ip>]
Apr 4 15:55:54 v01 postfix/pipe[6458]: 279741BE050: to=<<some-receiver>@yahoo.com.tw>, relay=spamassassin, delay=10, delays=6.1/0/0/4.1, dsn=2.0.0, status=sent (delivered via spamassassin service)
Apr 4 15:55:54 v01 postfix/pipe[6458]: 279741BE050: to=<<another-receiver>@yahoo.com.tw>, relay=spamassassin, delay=10, delays=6.1/0/0/4.1, dsn=2.0.0, status=sent (delivered via spamassassin service)
Apr 4 15:55:54 v01 postfix/pipe[6458]: 279741BE050: to=<<another-receiver>@yahoo.com.tw>, relay=spamassassin, delay=10, delays=6.1/0/0/4.1, dsn=2.0.0, status=sent (delivered via spamassassin service)
... und noch viele weitere Empfänger an yahoo.com.tw
Apr 4 15:55:54 v01 postfix/qmgr[18744]: 279741BE050: removed
|
Dass yahoo.com.tw das dann irgendwann geblockt hat, muss ich nicht weiter erwähnen.
Mein Server ist mit TLS und smtpd_tls_auth_only = yes konfiguriert. Die zu dem Zeitpunkt gesetzten smtp_recipient_restrictions waren:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # Allow no malformed mails
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unknown_sender_domain,
reject_unknown_recipient_domain,
# Allow our authed. users
permit_sasl_authenticated,
permit_mynetworks,
# These rejects may have to be disalbed, watch your logs
reject_invalid_helo_hostname,
reject_unknown_helo_hostname,
reject_non_fqdn_helo_hostname,
reject_unknown_client_hostname,
reject_unknown_reverse_client_hostname,
reject_rbl_client ix.dnsbl.manitu.net,
reject_rbl_client zen.spamhaus.org,
reject_unauth_destination,
check_policy_service inet:127.0.0.1:12525,
check_sender_mx_access cidr:/etc/postfix/bogus_mx
permit
|
Wenn ich nun meinen Server durch Open Relay Tests, wie diese:
* http://www.mailradar.com/openrelay/
* http://www.aupads.org/test-relay.html
jage, sagen sie mir, dass mein Server kein Open Relay ist.
Wenn ich mit Thunderbird auf Port 25 oder 587 ohne Authentifizierung etwas senden möchte, komme ich nicht durch.
Da die Log-files aber auch keinen Benutzeraccount auflisten, sieht das für mich so aus, als ob auch kein echter Benutzeraccount kompromittiert wurde. Von daher bin ich etwas unschlüssig, warum mein Server:
1. Diese E-Mails akzeptiert und nicht zurückweist
2. Im "From" eine E-Mailadresse annimmt, die nichts mit meiner Domain zu tun hat. Hat jemand eine Idee warum - oder wie ich dem eher auf die Schliche kommen könnte? Vielen Dank!
alias5000
|
sebix
Moderator, Webteam
Anmeldungsdatum: 14. April 2009
Beiträge: 5334
|
Bitte poste die gesamte main.cf und master.cf. Es ist hier nicht klar, welche restrictions das sind, und auf welchen Ports die gelten.
|
alias5000
(Themenstarter)
Anmeldungsdatum: 26. Dezember 2006
Beiträge: 51
|
Hi Sebix,
voila: main.cf 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 | # See /usr/share/postfix/main.cf.dist for a commented, more complete version
# dieser Wert wird zusammen mit HELO/EHLO bei fremden Servern benutzt (MX Record)
myhostname = meine-domain.de
# der Domain-Name des Systems (ohne Subdomain)
mydomain = meine-domain.de
# dieser Wert wird benutzt, um lokale E-Mails mit korrektem Domain-Part zu versehen (e.g. www-data@example.com)
myorigin = $mydomain
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/path/to/crt/file.crt
smtpd_tls_key_file=/path/to/key/file.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_tls_auth_only = yes
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
smtp_tls_security_level = may
smtp_tls_loglevel = 1
smtp_tls_CAfile = /path/to/ca-certificates.crt
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = debian.local, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
message_size_limit = 40960000
recipient_delimiter =
inet_interfaces = all
inet_protocols = all
# Virtual mailbox settings
virtual_mailbox_domains = proxy:mysql:$config_directory/mysql_virtual_domains_maps.cf
virtual_mailbox_base = /var/vmail
virtual_mailbox_maps =
proxy:mysql:$config_directory/mysql_virtual_mailbox_maps.cf,
proxy:mysql:$config_directory/mysql_virtual_alias_domain_mailbox_maps.cf,
proxy:mysql:$config_directory/mysql_virtual_alias_domain_catchall_maps.cf
virtual_alias_maps =
proxy:mysql:$config_directory/mysql_virtual_alias_maps.cf,
proxy:mysql:$config_directory/mysql_virtual_alias_domain_maps.cf
virtual_mailbox_limit = proxy:mysql:$config_directory/mysql_virtual_mailbox_limit_maps.cf
#virtual_mailbox_limit_override = yes
#virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
#virtual_overquota_bounce = yes
virtual_minimum_uid = 150
virtual_uid_maps = static:150
virtual_gid_maps = static:8
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
# SASL Authentication
smtpd_sasl_auth_enable = yes
smtpd_sasl_exceptions_networks = $mynetworks
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = no
smtpd_sasl_type = dovecot
queue_directory = /var/spool/postfix
smtpd_sasl_path = private/auth
smtpd_recipient_restrictions =
# Allow Postmaster, Abuse and other imporant role accounts
check_recipient_access btree:/etc/postfix/maps/access_recipient-rfc,
# White- and Blacklisting
check_client_access btree:/etc/postfix/maps/access_client,
check_helo_access btree:/etc/postfix/maps/access_helo,
check_sender_access btree:/etc/postfix/maps/access_sender,
check_recipient_access btree:/etc/postfix/maps/access_recipient,
# Allow no malformed mails
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unknown_sender_domain,
reject_unknown_recipient_domain,
# Allow our authed. users
permit_sasl_authenticated,
permit_mynetworks,
# These rejects may have to be disalbed, watch your logs
reject_invalid_helo_hostname,
reject_unknown_helo_hostname,
reject_non_fqdn_helo_hostname,
reject_unknown_client_hostname,
reject_unknown_reverse_client_hostname,
# check RBLs
reject_rbl_client ix.dnsbl.manitu.net,
reject_rbl_client zen.spamhaus.org,
# Greylisting
check_policy_service inet:127.0.0.1:60000,
# No other relaying
reject_unauth_destination,
# Policyd-Weight
check_policy_service inet:127.0.0.1:12525,
check_sender_mx_access cidr:/etc/postfix/bogus_mx
# Bogus Ans Ende der Restriktionen
# allow the rest
permit
# DKIM
milter_default_action = accept
milter_protocol = 2
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891
#ClamAV
content_filter = scan:127.0.0.1:10025
receive_override_options = no_address_mappings
|
master.cf:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129 | #
# Postfix master process configuration file. For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (yes) (never) (100)
# ==========================================================================
smtp inet n - - - - smtpd -o content_filter=spamassassin
submission inet n - - - - smtpd
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING
smtps inet n - - - - smtpd
-o syslog_name=postfix/smtps
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING
#628 inet n - - - - qmqpd
pickup fifo n - - 60 1 pickup
cleanup unix n - - - 0 cleanup
qmgr fifo n - n 300 1 qmgr
#qmgr fifo n - n 300 1 oqmgr
tlsmgr unix - - - 1000? 1 tlsmgr
rewrite unix - - - - - trivial-rewrite
bounce unix - - - - 0 bounce
defer unix - - - - 0 bounce
trace unix - - - - 0 bounce
verify unix - - - - 1 verify
flush unix n - - 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - - - - smtp
relay unix - - - - - smtp
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - - - - showq
error unix - - - - - error
retry unix - - - - - error
discard unix - - - - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - - - - lmtp
anvil unix - - - - 1 anvil
scache unix - - - - 1 scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent. See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop unix - n n - - pipe
flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
# lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
# mailbox_transport = lmtp:inet:localhost
# virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus unix - n n - - pipe
# user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix - n n - - pipe
# flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp unix - n n - - pipe
flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail unix - n n - - pipe
flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp unix - n n - - pipe
flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix - n n - 2 pipe
flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman unix - n n - - pipe
flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
${nexthop} ${user}
dovecot unix - n n - - pipe flags=DRhu
user=vmail:mail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}
spamassassin unix - n n - - pipe
user=spamassassin argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
#ClamAV
# AV scan filter (used by content_filter)
scan unix - - n - 16 smtp -o smtp_send_xforward_command=yes
# For injecting mail back into postfix from the filter
127.0.0.1:10026 inet n - n - 16 smtpd
-o content_filter=
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks_style=host
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
|
access_sender und access_helo, die als maps in main.cf drinnen sind, enthalten beide die öffentliche Server-IP im Format
bogus_mx:
1
2
3
4
5
6
7
8
9
10
11
12 |
# bogus networks
0.0.0.0/8 550 Mail server in broadcast network
1.0.0.0/8 550 Mail server in IANA reserved network
10.0.0.0/8 550 No route to your RFC 1918 network
127.0.0.0/8 550 Mail server in loopback network
224.0.0.0/4 550 Mail server in class D multicast network
172.16.0.0/12 550 No route to your RFC 1918 network
192.168.0.0/16 550 No route to your RFC 1918 network
69.6.0.0/18 550 REJECT Listed on Register Of Known Spam Operations
64.94.110.11/32 550 REJECT VeriSign Domain wildcard
|
Muchas gratias!
|
alias5000
(Themenstarter)
Anmeldungsdatum: 26. Dezember 2006
Beiträge: 51
|
|
sebix
Moderator, Webteam
Anmeldungsdatum: 14. April 2009
Beiträge: 5334
|
Das Problem ist dein Helo-Check. Die Reihenfolge der restrictions sind wichtig. | smtpd_recipient_restrictions =
[...]
check_helo_access btree:/etc/postfix/maps/access_helo,
[...]
reject_invalid_helo_hostname,
reject_unknown_helo_hostname,
reject_non_fqdn_helo_hostname,
[...]
permit
|
access_sender und access_helo, die als maps in main.cf drinnen sind, enthalten beide die öffentliche Server-IP im Format
Du pruefst erst, ob der Helo deine IP ist. Aber erst danach, ob der verbindende Client ueberhaupt zum Helo passt! Dieser Fall wird explizit in der Dokumentation aufgefuehrt: SMTPD_ACCESS_README Dangerous use of smtpd_recipient_restrictions Uebrigens kannst du deine restrictions aufteilen und zu unterschiedlichen Zeiten effektiv schalten lassen. So wird smtpd_client_restrictions beim connecten angewandt, smtpd_helo_restrictions bei gesandtem Helo, etc.
|
alias5000
(Themenstarter)
Anmeldungsdatum: 26. Dezember 2006
Beiträge: 51
|
Danke Sebix, das ergibt Sinn ☺
Ich werds jetzt mal eine Weile beobachten und mich zurück melden, falls etwas unklar ist. Bisher scheints zu funktionieren. Hatte meine temporären Lösungen gerade deaktiviert und ich scheine keinen Open Relaz für diese Spamwelle mehr zu haben (denn die Bots laufen immer noch von variierenden dznamischen IPs... ein Hoch auf zen.spamhaus). Herzlichen Dank!
|