Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exim: DoS vermeiden

29 views
Skip to first unread message

Paul Muster

unread,
Apr 29, 2021, 3:22:03 PM4/29/21
to
Hallo zusammen,

hier[tm] gab es heute nachmittag eine - beabsichtigte oder
unebabsichtigte - DoS-Attacke, die dazu führte, dass Exim keine weiteren
Verbindungen annahm:

2021-04-29 15:35:27 Connection from [a.b.c.d] refused: too many connections
2021-04-29 15:35:41 Connection from [e.f.g.h] refused: too many connections
2021-04-29 15:37:04 Connection from [k.l.m.n] refused: too many connections

Ich habe daraufhin dies gesetzt:

smtp_accept_max_per_host = 10
#smtp_accept_max = 20 # das ist der Default

Meiner Meinung nach ist das eine sinnvolle Gegenmaßnahme.

https://www.exim.org/exim-html-current/doc/html/spec_html/ch-main_configuration.html

---

smtp_accept_max Use: main Type: integer Default: 20

This option specifies the maximum number of simultaneous incoming SMTP
calls that Exim will accept. It applies only to the listening daemon;
there is no control (in Exim) when incoming SMTP is being handled by
inetd. If the value is set to zero, no limit is applied. However, it is
required to be non-zero if either smtp_accept_max_per_host or
smtp_accept_queue is set. See also smtp_accept_reserve and
smtp_load_reserve.

A new SMTP connection is immediately rejected if the smtp_accept_max
limit has been reached. If not, Exim first checks
smtp_accept_max_per_host. If that limit has not been reached for the
client host, smtp_accept_reserve and smtp_load_reserve are then checked
before accepting the connection.

smtp_accept_max_per_host Use: main Type: string† Default: unset

This option restricts the number of simultaneous IP connections from a
single host (strictly, from a single IP address) to the Exim daemon. The
option is expanded, to enable different limits to be applied to
different hosts by reference to $sender_host_address. Once the limit is
reached, additional connection attempts from the same host are rejected
with error code 421. This is entirely independent of
smtp_accept_reserve. The option’s default value of zero imposes no
limit. If this option is set greater than zero, it is required that
smtp_accept_max be non-zero.

Warning: When setting this option you should not use any expansion
constructions that take an appreciable amount of time. The expansion and
test happen in the main daemon loop, in order to reject additional
connections without forking additional processes (otherwise a
denial-of-service attack could cause a vast number or processes to be
created). While the daemon is doing this processing, it cannot accept
any other incoming connections.

---

Gibt es andere Meinungen? Sonstige Kommentare und/oder Ergänzungen?


Danke & viele Grüße

Paul

Paul Muster

unread,
Apr 29, 2021, 3:42:04 PM4/29/21
to
Hallo zusammen,

hier[tm] gab es heute nachmittag eine - beabsichtigte oder
unebabsichtigte - DoS-Attacke, die dazu führte, dass Exim keine weiteren
Verbindungen annahm:

2021-04-29 15:35:27 Connection from [a.b.c.d] refused: too many connections
2021-04-29 15:35:41 Connection from [e.f.g.h] refused: too many connections
2021-04-29 15:37:04 Connection from [k.l.m.n] refused: too many connections

Es waren zahlreiche Verbindungen von _einer_ Quell-IP aufgebaut, aber
offenbar nicht wieder abgebaut worden. Dadurch war das Limit (20, s.u.)
erreicht und andere Hosts konnten keine Mails einliefern.

Ich habe daraufhin dies gesetzt:

smtp_accept_max_per_host = 10
#smtp_accept_max = 20 # das ist der Default

Meiner Meinung nach ist das eine sinnvolle Gegenmaßnahme. Klar, einen
/Distributed/ DoS-Angriff kann man damit nicht bekämpfen, aber eine
Situation wie heute nachmittag mEn schon.

Tim Ritberg

unread,
Apr 29, 2021, 4:00:45 PM4/29/21
to
Am 29.04.21 um 21:33 schrieb Paul Muster:
> Hallo zusammen,
>
> hier[tm] gab es heute nachmittag eine - beabsichtigte oder
> unebabsichtigte - DoS-Attacke, die dazu führte, dass Exim keine weiteren
> Verbindungen annahm:
>
> 2021-04-29 15:35:27 Connection from [a.b.c.d] refused: too many connections
> 2021-04-29 15:35:41 Connection from [e.f.g.h] refused: too many connections
> 2021-04-29 15:37:04 Connection from [k.l.m.n] refused: too many connections
>

Solche Nervensägen filter ich mit Netfilter raus:

iptables -A INPUT -i $EXT -p tcp --dport 25 -m state --state NEW -m
hashlimit --hashlimit-above 2/h --hashlimit-burst 2 --hashlimit-mode
srcip --hashlimit-name mailattack -j REJECT

iptables -A INPUT -i $EXT -p tcp --dport 25 -j ACCEPT


Tim

--
Eine Firewall ist kein Konzept! RTFM: RFC 2979

Ralph Angenendt

unread,
Apr 30, 2021, 6:32:52 AM4/30/21
to
Well, Tim Ritberg <t...@server.invalid> wrote:
> Am 29.04.21 um 21:33 schrieb Paul Muster:
>> Hallo zusammen,
>>
>> hier[tm] gab es heute nachmittag eine - beabsichtigte oder
>> unebabsichtigte - DoS-Attacke, die dazu führte, dass Exim keine weiteren
>> Verbindungen annahm:
>>
>> 2021-04-29 15:35:27 Connection from [a.b.c.d] refused: too many connections
>
> Solche Nervensägen filter ich mit Netfilter raus:
>
> iptables -A INPUT -i $EXT -p tcp --dport 25 -m state --state NEW -m
> hashlimit --hashlimit-above 2/h --hashlimit-burst 2 --hashlimit-mode
> srcip --hashlimit-name mailattack -j REJECT

2 Verbindungen pro Stunde?

Ralph
--
Übervaterlandverräter und Mutterkornblumenblau

Tim Ritberg

unread,
Apr 30, 2021, 7:25:06 AM4/30/21
to
Am 30.04.21 um 12:32 schrieb Ralph Angenendt:
Kommt drauf an, welche Domains gehostet werden, und weitere MXer hast du
ja sicher auch noch.
Mit ACCEPT-Regeln kannst du noch bekannte Server wie GMX, Gmail etc
durchlassen.

Tim

Tim Ritberg

unread,
Apr 30, 2021, 7:26:13 AM4/30/21
to
Am 30.04.21 um 12:32 schrieb Ralph Angenendt:
Das ist pro Absender-IP!
Witere MXer hast du ja sicher auch noch.

Thomas Hochstein

unread,
Apr 30, 2021, 1:45:02 PM4/30/21
to
Paul Muster schrieb:

> Meiner Meinung nach ist das eine sinnvolle Gegenmaßnahme.

Die entsprechenden Werte für die Limits wählt man sinnvollerweise so
klein, dass der Server kein Lastproblem bekommt, und ansonsten so groß
wie möglich - dann lehnt man Mail nur ab, wenn das sein muss, weil
ansonsten die Stabilität der ganzen Maschine bedroht ist.

-thh

Heiko Schlichting

unread,
May 2, 2021, 7:25:48 AM5/2/21
to
Paul Muster <exp-3...@news.muster.net> wrote:
> smtp_accept_max_per_host = 10
> #smtp_accept_max = 20 # das ist der Default
[...]
> Gibt es andere Meinungen? Sonstige Kommentare und/oder Ergänzungen?

Die Werte hängen von so vielen Faktoren ab, dass man dazu keine allgemein
gültigen Aussagen treffen kann. Wenn es sich um ein System handelt, welches
sehr wenig Mail bekommt und extrem schwach ausgestattet ist, so mag der
niedrige Wert für smtp_accept_max in Ordnung sein. Andererseits ist
smtp_accept_max_per_host bei 50% von smtp_accept_max, was sehr viel und nur
sinnvoll ist, wenn man die meisten E-Mails von einer IP-Adresse bekommt.

Bei mir sind die Werte auf Mailservern, die aus dem Internet erreichbar
sind, so¹ gesetzt:

smtp_accept_max_per_host = 5
smtp_accept_max = 1500

Heiko

¹ vereinfachte Variante, denn in Wirklichkeit werden die Werte in
Abhängigkeit der einliefernden IP-Adresse gesetzt, z.B.
smtp_accept_max_per_host = ${if match_ip{$sender_host_address}{+mynetwork}{250}{5}}
0 new messages