Hi,
On Tue, Dec 6, 2016 at 9:24 AM, /dev/rob0 <[email protected]> wrote:
> On Tue, Dec 06, 2016 at 08:59:56AM +0100, Julian Kippels wrote:
>> Am Mon, 5 Dec 2016 20:52:21 -0500
>> schrieb Alex <[email protected]>:
>>
>> > I have a postfix-3.0.5 system with a few hundred users. They
>> > have access to submission, webmail, and dovecot to send and
>> > receive mail.
>> >
>> > On occasion, user's local desktop are compromised, and with it
>> > their account on this system. This leads to their local desktop
>> > using the submission service to send hundreds or thousands of
>> > spam emails through this compromised account.
>
> As another poster pointed out, sometimes the credentials have been
> shared with a botnet, and the spam can come from around the world.
> It's not only a matter of a desktop machine compromise. Sometimes
> mobile devices (phones, tablets) are involved.
This is exactly what's happened. There are still dozens of different
IP addresses attempting to login to the account.
> There were numerous suggestions upthread which are of varying
> usefulness, depending on site-specific requirements, but Julian's
> answer here is the best overall for generic use, of what I have seen
> before starting this post. But it's not complete and can stand some
> improvement. :)
I started with the suggestion regarding creating the
mua_relay_restrictions to prevent users from sending as other than our
domain:
mua_relay_restrictions =
check_sender_access hash:/etc/postfix/sasl-mydomain, reject
smtpd_relay_restrictions = reject_unauth_destination
This worked great, until I learned there are legitimate users sending
mail as domains other than ours, resulting in Relay Access Denied
errors. I'm pretty sure there's only a few though, so perhaps it's
worth it to play whack-a-mole and try and keep an updated list?
>> I use a policy deamon that registers every mail that is sent by
>> our servers. The metadata is stored in a SQL Database. Every two
>> minutes a cronjob is run which checks the metadata for which
>> sasl_sender has send how many mails. If a sasl_sender surpasses
>> a certain threshold the cronjob automatically blocks this user
>> in our LDAP so that he can't submit any more mails.
Introducing another process is something I'd like to avoid, but if you
all think this is the best approach, then I'll figure it out.
> What I have seen of these things suggests that the malware goes like
> a fire hose. They know they have a limited time before your site
> gets listed as a spam source, so they launch as much as they can as
> long as they can.
In this case, it was actually going on for days, little by little. Not
enough to cause a problem with the queue or alarm any of the
administrators (me, really).
> Now, as for what Julian's reply was missing: first, maintain strict
> separation of user submission from MX (inbound, port 25) mail.
It appears we're currently offering STARTTLS on 25:
$ telnet mail01 25
Trying 66.222.333.100...
Connected to mail01.
Escape character is '^]'.
220 mail01.example.com ESMTP Postfix
ehlo localhost
250-mail01.example.com
250-PIPELINING
250-SIZE 24000000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 SMTPUTF8
> Perhaps you already do this. The best practice recommendation is
> that SASL AUTH should only be offered on the submission service, by
> means of an " -o smtpd_sasl_auth_enable=yes" in master.cf. If you
> have legacy users you don't control, submitting on port 25, use a
> separate IP address for that. And the hostname given to your users
> to set up their MUAs must not be one of the published MX names.
We're also offering it on 587, which is what I believe we have as the
documented method for sending mail.
How can I determine if users are indeed using port 25, and if so, turn it off?
submission inet n - n - - smtpd
-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
-o receive_override_options=$submission_overrides
-o syslog_name=postfix/submission
It looks like this is what's enabling it on port 25:
smtps inet n - 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
Maybe adding "-o syslog_name=postfix/smtps" would help to identify
them in the logs?
> Next, use content filtering on submission. You can't use the same
> kind of tests that you use on MX mail, which is why the above
> separation is mentioned. But URIBL lookups are extremely effective
> against these.
That sounds like a great idea. Do I do it with rbl_reply_maps? How can
it be configured to only affect outbound mail? Inbound mail is already
filtered at the gateway.
> Another potential improvement to the policy daemon is as Sebastian
> suggested upthread: geoip lookups. If you're seeing connections
The addresses are global. I have no idea where any one particular
address is located. If there was a way to determine this by trusting
the IP that's currently being used, and using that to determine where
they are, then we could do that.
If so, where do I get started with setting up this geoip lookups with postfix?