ALT Linux sysadmins discussion
 help / color / mirror / Atom feed
From: Michael Shigorin <mike@osdn.org.ua>
To: sysadmins@lists.altlinux.org
Subject: [Sysadmins] apache DoS by slowloris
Date: Mon, 6 Jul 2009 21:13:17 +0300
Message-ID: <20090706181317.GA28185@osdn.org.ua> (raw)

	Здравствуйте.
Думал было упаковать slowloris и mod_qos, но похоже, сегодня не
успею, а потом забуду -- решил по крайней мере письмом описать.

Как известно, apache с моделью "один клиент -- один процесс"
(или одна нить, не суть важно) уязвим к слишком большому
количеству соединений, когда выедается память.  Поэтому обычно
лимиты на количество соединений устанавливаются "в разумных
пределах".  Правда, при этом возможно организовать отказ в
обслуживании методом создания и поддержания соответствующего
количества соединений.

По адресу http://ha.ckers.org/slowloris/ не так давно был
опубликован скрипт, использующий довольно давно известные
моменты, но переводящий их в практическое русло и весьма
эффективно DoS'ящий apache 1.x/2.x (в отличие от IIS 6/7,
lighttpd и nginx).  В логах не отсвечивает, заметен только
по стопке ESTABLISHED в `netstat -pan | grep httpd`.

Насколько понимаю, из используемого мной:
* mod_security неэффективен, поскольку до него дело не доходит;
* mod_limitipconn умеренно эффективен, поскольку не занимается
  сокетами (?);
* nginx может быть неэффективен, если до backend apache
  "долетает" достаточное количество таких тормозных соединений.

До mod_qos руки не дошли, пока кажется достаточным добавление в
секцию http{} уже используемого в качестве реверс-прокси nginx:

     client_header_timeout 11;
     client_body_timeout 11;
     keepalive_timeout 11;
     send_timeout 11;
#    limit_zone   slowdown  $binary_remote_addr  1m;
#    limit_conn   slowdown  7;

при лимитах в httpd.conf (вероятно, ещё будут корректироваться):

Timeout 35
KeepAlive On
KeepAliveTimeout 65

MinSpareServers 1
MaxSpareServers 2
StartServers 4
#MaxClients 8
MaxClients 16

MaxRequestsPerChild 100
ListenBacklog 511

и подобной настройке mod_limitipconn:

<IfModule mod_limitipconn.c>
        <Location />
                MaxConnPerIP 2
        </Location>
        # ...
</IfModule>

Речь про apache-1.3.

См. тж.:
* http://ha.ckers.org/blog/20090620/http-longevity-during-dos/
* http://www.codexon.com/posts/defending-against-the-new-dos-tool-slowloris

-- 
 ---- WBR, Michael Shigorin <mike@altlinux.ru>
  ------ Linux.Kiev http://www.linux.kiev.ua/


             reply	other threads:[~2009-07-06 18:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-06 18:13 Michael Shigorin [this message]
2009-07-06 22:28 ` Денис Смирнов
2009-07-07  4:09   ` Max Ivanov
2009-07-07 17:33     ` Денис Смирнов
2009-07-08 15:38   ` Michael Shigorin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090706181317.GA28185@osdn.org.ua \
    --to=mike@osdn.org.ua \
    --cc=shigorin@gmail.com \
    --cc=sysadmins@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux sysadmins discussion

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/sysadmins/0 sysadmins/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 sysadmins sysadmins/ http://lore.altlinux.org/sysadmins \
		sysadmins@lists.altlinux.org sysadmins@lists.altlinux.ru sysadmins@lists.altlinux.com
	public-inbox-index sysadmins

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.sysadmins


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git