Yahoo Groups archive

Milter-greylist

Index last updated: 2026-04-28 23:32 UTC

Thread

Ratelimit per authenticated user

Ratelimit per authenticated user

2016-09-08 by maren.zubizarreta@...

Hello:


We want to implement an ACL with a ratelimit per authenticated user, this is to prevent SPAMMing when one of our user's credentials are stolen, and a SPAMMER using different IPs and the same user credentials tries to send SPAm throuh our system.

Is it possible to do it using milter-greylist? I haven't found how.


Thanks a lot


Maren

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by Marcus Schopen

Hi Maren,

On 2016-09-08 09:12, maren.zubizarreta@... [milter-greylist] wrote:
> Hello:
> 
>  We want to implement an ACL with a ratelimit per authenticated user,
> this is to prevent SPAMMing when one of our  user's credentials are
> stolen, and a SPAMMER using different IPs and the same user
> credentials tries to send SPAm throuh our system.
> 
> Is it possible to do it using milter-greylist? I haven't found how.

Would interest me too, good idea! Do you think changing IPs on a 
smtp-auth account is a good hint of abuse? What if all spam is sent from 
one IP, e.g. if a users notebook is infected by a virus and uses your 
smtp relay to send spam. May be a hard limit number for a user account 
combined with changing IPs and/or geoip.

Ciao
Marcus

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by Marcus Schopen

On 2016-09-08 09:39, Marcus Schopen lists-yahoogroups@... 
[milter-greylist] wrote:
> Hi Maren,
> 
> On 2016-09-08 09:12, maren.zubizarreta@... [milter-greylist] wrote:
>> Hello:
>> 
>> We want to implement an ACL with a ratelimit per authenticated user,
>> this is to prevent SPAMMing when one of our user's credentials are
>> stolen, and a SPAMMER using different IPs and the same user
>> credentials tries to send SPAm throuh our system.
>> 
>> Is it possible to do it using milter-greylist? I haven't found how.
> 
> Would interest me too, good idea! Do you think changing IPs on a
> smtp-auth account is a good hint of abuse? What if all spam is sent
> from
> one IP, e.g. if a users notebook is infected by a virus and uses your
> smtp relay to send spam. May be a hard limit number for a user account
> 
> combined with changing IPs and/or geoip.

Some examples/ideas:

http://myspew.com/software/how-to-rate-limit-smtp-with-milter-greylist

and see for "Rate Limit" in greylist.conf. Not exact your case, but some 
ideas.

Ciao!

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by maren.zubizarreta@...

Hello again,

We want to limit both cases, this is, when an authenticated user sends more than X mails, just stop it.

We use milter-greylist since 2012, but now we desperately need to set this pratelimit.

We have checked other products and with policyID (https://mtpolicyd.org/) you can do it easily, now I wonder if it's possible to do it with milter-greylist.
Maren

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by maren.zubizarreta@...

Thanks,
We actually have such rules:

list "HORDE" addr { 10.0.100.41 10.0.100.42 10.0.100.43 10.0.100.44 10.0.100.45 }
ratelimit "MAILS_PER_HOUR" rcpt 200 / 1h key "%f"
racl blacklist list "HORDE" ratelimit "MAILS_PER_HOUR" msg "Quota Exceeded"

But we only can use %f and other parameters specified at the manual.
The point is that we want to use as a parameter, the SASL authenticated user, and I don't know if we can do it and how.

Thanks



Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by Serge Stepanov

maybe to use auth macro as key

key %M{auth_authen}%i

Show quoted textHide quoted text
I didnt test this...

Reply via web post Reply to sender Reply to group Start a New TopicMessages in this topic (5)
Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.

.


Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by Emmanuel Dreyfus

On Thu, Sep 08, 2016 at 12:12:38AM -0700, maren.zubizarreta@... [milter-greylist] wrote:
>   We want to implement an ACL with a ratelimit per authenticated user, this is to prevent SPAMMing when one of our  user's credentials are stolen, and a SPAMMER using different IPs and the same user credentials tries to send SPAm throuh our system.
>  Is it possible to do it using milter-greylist? I haven't found how.

I use that, assuming users post from 192.0.2.0/24

ratelimit "users" rcpt 100 / 10m key "%M{auth_authen}"
racl blacklist addr 192.0.2.0/24 ratelimit "users" \
        msg "Too many recipients (%M{auth_authen}), please retry later"

In sendmail.cf, you need O Milter.macros.envfrom to contain {auth_authen}

-- 
Emmanuel Dreyfus
manu@...

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by maren.zubizarreta@...

Thanks:

I think I have it, my only doubt is how would you set exception's as these proposed by Can, for unauthenticated user, or for a specific user, would you still use sm_macro?
Maren

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by Serge Stepanov

Btw,

Could you explain how ratelimit is accounting?

It account all events or only when any acl trig ?

For example i want to count only spam messages at data stage. i use

ratelimit "spam hosts" rcpt 25 / 3h
dacl blacklist spamd > 5 ratelimit "spam hosts" flushaddr code "421" ecode "4.7.0"

this ratelimit count ALL messages per ip or only ones matched this dacl ?


Thanks
Show quoted textHide quoted text
On Thu, Sep 8, 2016 at 12:55 PM, Emmanuel Dreyfus manu@... [milter-greylist] <milter-greylist@yahoogroups.com> wrote:

On Thu, Sep 08, 2016 at 12:12:38AM -0700, maren.zubizarreta@... [milter-greylist] wrote:
> We want to implement an ACL with a ratelimit per authenticated user, this is to prevent SPAMMing when one of our user's credentials are stolen, and a SPAMMER using different IPs and the same user credentials tries to send SPAm throuh our system.
> Is it possible to do it using milter-greylist? I haven't found how.

I use that, assuming users post from 192.0.2.0/24

ratelimit "users" rcpt 100 / 10m key "%M{auth_authen}"
racl blacklist addr 192.0.2.0/24 ratelimit "users" \
msg "Too many recipients (%M{auth_authen}), please retry later"

In sendmail.cf, you need O Milter.macros.envfrom to contain {auth_authen}

--
Emmanuel Dreyfus
manu@...


Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by Emmanuel Dreyfus

On Thu, Sep 08, 2016 at 03:18:59AM -0700, maren.zubizarreta@... [milter-greylist] wrote:
>   I think I have it, my only doubt is how would you set exception's as these proposed by Can, for unauthenticated user, or for a specific user, would you still use sm_macro?

{auth_authen} contains the authenticated userid. You can make specific rules for specific values if you want.

-- 
Emmanuel Dreyfus
manu@...

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by maren.zubizarreta@...

Hi Btw,

As I understand it, in your example you are acounting all mesages, but you can tune this using "key", for example:

ratelimit "spam hosts" rcpt 25 / 3h key "%f" -->it accounts messages with the same from
ratelimit "spam hosts" rcpt 25 / 3h key "%i" -->it accounts messages with the same IP
ratelimit "spam hosts" rcpt 25 / 3h key "%f%i" -->it accounts messages with the same from and IP


As for my problem I have already tested successfully the schema given by Can:

list "MY_IP" addr { 158.227.4.29}
ratelimit "limite_1H" rcpt 1 / 1m key "%M{auth_authen}"
sm_macro "null" "{auth_authen}" unset
sm_macro "user1_macro" "{auth_authen}" "user1"

racl blacklist not sm_macro "null" not sm_macro"user1_macro" list "MY_IP" ratelimit "limite_1H" msg "Quota exceeded"


Now, I would like to change the user name, so that I vcan have a list of then instead of one macro per user,
I have read that I can use regexp here using slashes:
sm_macro "user1_macro" "{auth_authen}" /user1|user2/
I'd like to ask if this is correct, or I should rather use a user_s list or something else.

Thanks

Maren



Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by maren.zubizarreta@...

Hello again:

I already tested the regular expression:
sm_macro "users_macro" "{auth_authen}" /user1|user2/
and it seems to work well, so now my definitive config will be:

list "MY_NETWORKS" addr { 158.227.4.0/24}
ratelimit "limite_1H" rcpt 200 / 1h key "%M{auth_authen}"
sm_macro "null" "{auth_authen}" unset
sm_macro "users_macro" "{auth_authen}" /user1|user2/

racl blacklist not sm_macro "null" not sm_macro"users_macro" not list "MY_NETWORKS" ratelimit "limite_1H" msg "Quota exceeded"


Maren

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by maren.zubizarreta@...

Sorry, my last message was a mistake.

I have another question. For these rules to be applied I have to set "noauth", but then all other rules that I had before (such as default greylisting) are applied to authenticated users. Is there a way to organice the rules to avoid this?.

I mean, enabling the noauth at the end of my previous file, and adding at the end the new rules for authenticated users, would do the job?

Thanks

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-08 by Marcus Schopen

Hi,

On 2016-09-08 14:18, maren.zubizarreta@... [milter-greylist] wrote:
> Hello again:
> 
>  I already tested the regular expression:
> sm_macro "users_macro" "{auth_authen}" /user1|user2/
> and it seems to work well, so now my definitive config will be:
> 
> list "MY_NETWORKS" addr { 158.227.4.0/24}
> ratelimit "limite_1H" rcpt 200 / 1h key "%M{auth_authen}"
> sm_macro "null" "{auth_authen}" unset
> sm_macro "users_macro" "{auth_authen}" /user1|user2/
> 
> racl blacklist not sm_macro "null" not sm_macro"users_macro" not  list
> "MY_NETWORKS" ratelimit "limite_1H" msg "Quota exceeded"

Thanks for your example. I tried your rule set, which is placed before 
"racl greylist list "grey users" ..." in the config, but it's not 
working here:

-------
# Limit Test
list "MY_NETWORKS" addr { 192.168.100.0/24}
ratelimit "limite_1H" rcpt 2 / 1h key "%M{auth_authen}"
sm_macro "null" "{auth_authen}" unset
sm_macro "users_macro" "{auth_authen}" /user1|user2/
racl blacklist not sm_macro "null" not sm_macro "users_macro" not list 
"MY_NETWORKS" ratelimit "limite_1H" msg "Quota exceeded"
-------

grep auth_authen sendmail.cf:
O Milter.macros.envfrom=i, {auth_type}, {auth_authen}, {auth_ssf}, 
{auth_author}, {mail_mailer}, {mail_host}, {mail_addr}
...

sendmail.mc:
INPUT_MAIL_FILTER(`greylist',`S=inet:12345@internalscanhost, F=, 
T=S:1m;R:1m')dnl

mail.log says:
Sep  8 19:10:50 internalscanhost milter-greylist: User testuser1 
authenticated, bypassing greylisting

Andy ideas?

Ciao
Marcus

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-09 by maren.zubizarreta@...

Hello again:
From the mesage "User testuser1 authenticated, bypassing greylisting"
I can guess that you haven't enabled "noauth", this is: uncomment it, so rules will be applied
to authenticated users.

Even so, yesterday I sent a question, as I'm not sure if it's possible to avoid greylisting for authenticated users, once noauth is enabled. Anybody knows?:

>>For these rules to be applied I have to set "noauth", but then all other rules that I had before (such as default >>greylisting) are applied to authenticated users. Is there a way to organice the rules to avoid this?.

>>I mean, enabling the noauth at the end of my previous file, and adding at the end the new rules for >>authenticated users, would do the job?

Thanks

Maren


Re: [milter-greylist] Ratelimit per authenticated user

2016-09-14 by manu@...

maren.zubizarreta@... [milter-greylist]
<milter-greylist@yahoogroups.com> wrote:

>  I mean, enabling the noauth at the end of my previous file, and adding at
> the end the new rules for authenticated users, would do the job?

I understand it would.

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu@...

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-14 by manu@...

maren.zubizarreta@... [milter-greylist]
<milter-greylist@yahoogroups.com> wrote:

>  Even so, yesterday I sent a question, as I'm not sure if it's possible to
> avoid greylisting for authenticated users, once noauth is enabled.
> Anybody knows?:

Default behavior is there for backward compatibility. It whitelists
authenticated users.

If you use noauth, authenticated users go through the ACL as others do.
Then you can have specific ACL for authenticated users.

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu@...

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-14 by Marcus Schopen

Hi Maren,

On 2016-09-08 09:12, maren.zubizarreta@... [milter-greylist] wrote:
> Hello:
> 
>  We want to implement an ACL with a ratelimit per authenticated user,
> this is to prevent SPAMMing when one of our  user's credentials are
> stolen, and a SPAMMER using different IPs and the same user
> credentials tries to send SPAm throuh our system.
> 
> Is it possible to do it using milter-greylist? I haven't found how.

Have you thought about fail2ban, not just classic firewall rules, but 
closing smtp accounts if successful smtp logins come from different IPs 
in a very short time period, possibly combining with geoip? Beside 
ratelimits this might be a way to block abusing accounts. I posted that 
question on fail2ban list today.

Ciao!
Marcus

Re: [milter-greylist] Ratelimit per authenticated user

2016-09-15 by Frank Doepper

Am 14.09.16 um 15:36 schrieb Marcus Schopen lists-yahoogroups@......:

> Have you thought about fail2ban, not just classic firewall rules, but
> closing smtp accounts if successful smtp logins come from different IPs
> in a very short time period, possibly combining with geoip? Beside
> ratelimits this might be a way to block abusing accounts. I posted that
> question on fail2ban list today.

I have built this with mimedefang and a SQLite-DB. I have running both
mimedefang and milter-greylist on the server. And fail2ban (for
unsuccessful logins), too. Hard times.

Frank.
-- 
xmpp:fd@...
pgp:0x6C6804CD

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.