ModSecurityでブルートフォース攻撃を防御するには
標題のテーマ、日本語では情報が得られなかった、、、
まぁ、あれこれググるよりもルールをきちんと理解していれば
自分で考えて設定できるはずなのだが、残念ながらまだ無理(汗)。
とりあえず、英語で見つけた以下の設定がお手本になりそうではある。
(英語でもこれくらいしか見当たらなかったな〜)
英語部分は完全に抜粋である。日本語部分はほぼ意訳である。
↓ ↓ ↓
http://www.packtpub.com/article/blocking-common-attacks-using-modsecurity-2.5-part3
A good way to defend against brute force attacks is to allow a certain number of login attempts, say three, and after that start delaying or blocking further attempts.
Let’s see how we can use ModSecurity to accomplish this.
ブルートフォース攻撃の防御としてよい方法は、一定の回数のログイン試行
(例えば3回まで)は許可することだ。
以後は、それ以上のログイン試行は遅延させるかブロックさせる。
これを成し遂げるのにModSecurityをどう利用できるか見てみよう。
If your login verification page is situated at yoursite.com/login, then the following rules
will keep track of the number of login attempts by users:
あなたのログイン認証ページがyoursite.com/loginだとしたら、以下のルールによって
ユーザのログイン試行回数の記録をつけることができる。
#
# Block further login attempts after 3 failed attempts
#
<LocationMatch ^/login>
# Initalize IP collection with user’s IP address
SecAction “initcol:ip=%{REMOTE_ADDR},pass,nolog”
# Detect failed login attempts
SecRule RESPONSE_BODY “Username does not exist” “phase:4,pass,setvar:
ip.failed_logins=+1,expirevar:ip.failed_logins=60″
# Block subsequent login attempts
SecRule IP:FAILED_LOGINS “@gt 3″ deny
</Location>
The rules initialize the ip collection and increase the field ip.
failed_logins after each failed login attempt.
Once more than three failed logins are detected, further attempts are blocked.
The expirevar action is used to reset the number of failed login attempts to zero after
60 seconds, so the block will be in effect for a maximum of 60 seconds.
ルールはIPコレクションを初期化し、ログイン試行失敗の都度、そのIPの値は増える。
3回以上のログイン失敗が検知されると、それ以降のログイン試行はブロックされる。
expirevar アクションは、ブロックが最大60秒間有効になるように、60秒後に
ログイン試行失敗の回数をリセットするのに用いられる。
Another approach is to start delaying requests once the threshold number of login
attempts has been reached. This has the advantage of not denying access in case a
legitimate user has actually forgotten his password and needs more attempts to
remember it. Here are the rules to do that:
別のアプローチでは、ログイン試行の回数が閾値を超えたらリクエストの遅延を開始する。
これは正規のユーザがパスワードを実際に忘れてしまった場合にアクセスを拒否しないという利点がある。
そのようにするルールは以下。
#
# Throttle login attempts after 3 failed attempts
#
<LocationMatch ^/login>
SecAction “initcol:ip=%{REMOTE_ADDR},pass,nolog”
SecRule RESPONSE_BODY “Username does not exist” “phase:4,pass,setvar:
ip.failed_logins=+1,expirevar:ip.failed_logins=10″
SecRule IP:FAILED_LOGINS “@gt 3″ “phase:4,allow,pause:3000″
</Location>
The pause action is what delays the request, and the time specified is in milliseconds,
so the above will delay the response for three seconds once the limit of three failed login
attempts has been exceeded.
pauseアクションはリクエストに遅延を生じさせ、また指定の時間はミリセカンドなので、
上記は3回ログイン試行が失敗したらレスポンスを3秒遅らせることとなる。
引用したページには、他にも一般的なアタックへの対処例が挙げられており、参考になりそうである。
今度ちゃんと目を通しておこう。
ModSecurityは本当に日本語の情報が少ないが、こうなってくると英語でもよい
ページが見つかると感激ものだな。。