networkapp:waf:mod-security
差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン次のリビジョン両方とも次のリビジョン | ||
networkapp:waf:mod-security [2018/10/30 15:30] – [Monitor Modeの検証] seirios | networkapp:waf:mod-security [2018/11/01 18:26] – [DropModeWAF] seirios | ||
---|---|---|---|
行 3: | 行 3: | ||
NGINXを利用して、Proxy/ | NGINXを利用して、Proxy/ | ||
- | {{ : | ||
===== 構成 ===== | ===== 構成 ===== | ||
行 137: | 行 136: | ||
これで、NGINX+mod_security3のバイナリーがInstallされる。 | これで、NGINX+mod_security3のバイナリーがInstallされる。 | ||
+ | |||
+ | <WRAP round tip> | ||
+ | WAFを作成する場合に、logをHDDに書き出す場合、HDDの書き込み速度が律速になり、NGINX自体が遅くなることがある。 | ||
+ | しかし、WAFで、検査したRequestをできるだけ書き出したい場合もある。 | ||
+ | |||
+ | NGINXは、標準でsyslogにlogを書き出すことができるが、その場合、log文字数は2048文字でハードコードされている。\\ | ||
+ | ( '' | ||
+ | |||
+ | syslogは、仕様としてはlog文字長に制限はないが、FreeBSDの '' | ||
+ | (参照: [[serverapp: | ||
+ | |||
+ | この場合に、NGINXのlog文字列を増やし、かつ、Mod_Security3用の設定を毎回portsにて行うことは非常に面倒なので、portsを作成した。 | ||
+ | |||
+ | 以下、分かる人向け。 | ||
+ | |||
+ | BaseにしたNGINXは、個人の好みでnginx-develにした。気に入らない人は、Makefileを書き換えればnginxにもできる。 | ||
+ | |||
+ | '' | ||
+ | <code - Makefile> | ||
+ | # Created by: seirios | ||
+ | |||
+ | PORTNAME= | ||
+ | PKGNAMESUFFIX= | ||
+ | |||
+ | MAINTAINER= | ||
+ | COMMENT= | ||
+ | |||
+ | MASTERDIR= | ||
+ | |||
+ | CONFLICTS= | ||
+ | nginx-devel-1.* \ | ||
+ | nginx-full-1.* \ | ||
+ | nginx-naxsi-1.* | ||
+ | |||
+ | OPTIONS_DEFAULT=DSO FILE_AIO IPV6 THREADS WWW \ | ||
+ | HTTP HTTP_ADDITION HTTP_AUTH_REQ HTTP_CACHE HTTP_DAV HTTP_FLV \ | ||
+ | HTTP_GEOIP HTTP_REALIP HTTP_REWRITE HTTP_SSL HTTP_STATUS HTTPV2 \ | ||
+ | LUA MODSECURITY3 | ||
+ | |||
+ | .include " | ||
+ | </ | ||
+ | |||
+ | <code diff files/ | ||
+ | # cat files/ | ||
+ | --- src/ | ||
+ | +++ src/ | ||
+ | @@ -73,7 +73,7 @@ | ||
+ | }; | ||
+ | |||
+ | |||
+ | -#define NGX_MAX_ERROR_STR | ||
+ | +#define NGX_MAX_ERROR_STR | ||
+ | |||
+ | |||
+ | / | ||
+ | </ | ||
+ | あとは、通常通りmakeすれば良い。 | ||
+ | |||
+ | 見れば分かるが、基本 nginx-devel に依存し、参照するので、ngx_log.hが大幅に変更されない限り、継続して利用できるはずである。 | ||
+ | </ | ||
=== OWASP CRSのInstall === | === OWASP CRSのInstall === | ||
mod_security用のsignature dataは / | mod_security用のsignature dataは / | ||
行 146: | 行 205: | ||
</ | </ | ||
- | <WRAP tip> | + | < |
2018/ | 2018/ | ||
そのため、現在の段階では、以下の追加操作が必要になる。 | そのため、現在の段階では、以下の追加操作が必要になる。 | ||
行 158: | 行 217: | ||
この作業を行わないと、CRSの読み込みの段階で複数のエラーが発生して大ハマりすることになる。 | この作業を行わないと、CRSの読み込みの段階で複数のエラーが発生して大ハマりすることになる。 | ||
+ | |||
+ | なお、現在利用しているBranchを確認するには、'' | ||
</ | </ | ||
行 526: | 行 587: | ||
+- nginx -+- ... : FreeBSD portsによって作成される | +- nginx -+- ... : FreeBSD portsによって作成される | ||
+- modsec -+- MM-Base.conf | +- modsec -+- MM-Base.conf | ||
- | | +- MM.conf : MonitorMode WAF設定 | + | | +- MM0.conf |
- | | +- MM-preCRS.conf | + | | +- MM0-preLoad.conf : MonitorMode |
- | | +- MM-preLocal.conf : MonitorMode用local signature読み込み前設定 | + | | +- MM0-postLoad.conf : MonitorMode |
- | | +- MM-postCRS.conf | + | |
- | | +- MM-postLocal.conf : MonitorMode用local signature読み込み後設定 | + | |
| +- DM-Base.conf | | +- DM-Base.conf | ||
- | | +- DM.conf : DropMode WAF設定 | + | | +- DM0.conf |
- | | +- DM-preCRS.conf | + | | +- DM0-preLoad.conf : DropMode |
- | | +- DM-preLocal.conf : DropMode用local signature読み込み前設定 | + | | +- DM0-postLoad.conf : DropMode |
- | | +- DM-postCRS.conf | + | |
- | | +- DM-postLocal.conf : DropMode用local signature読み込み後設定 | + | |
+- conf.http | +- conf.http | ||
+- conf.http.d -+- ... : server/ | +- conf.http.d -+- ... : server/ | ||
行 628: | 行 685: | ||
# Preload of omitting signature | # Preload of omitting signature | ||
- | Include / | + | Include / |
- | Include / | + | |
# Include OWASP CRS Configurations and Signature Rules. | # Include OWASP CRS Configurations and Signature Rules. | ||
行 636: | 行 692: | ||
# Postload of omitting signature | # Postload of omitting signature | ||
- | Include / | + | Include / |
- | Include / | + | |
</ | </ | ||
- | - 以下、MM-(pre|post)(CRS|Local).confを作成する | + | - 以下、MM-(pre|post)Load.confを作成する |
- | - <code - MM-preCRS.conf> | + | - <code - MM-preLoad.conf> |
# | # | ||
- | # ModSecurity preload | + | # ModSecurity preload |
# | # | ||
- | # id: 1000 - 2999 | ||
#SecAction " | #SecAction " | ||
- | |||
- | # ModSecurity BUG. fixed at 3.1.0. | ||
- | #SecAction " | ||
- | </ | ||
- | - <code - MM-preLocal.conf> | ||
- | # | ||
- | # ModSecurity preload omitting signatures for Local signatures. | ||
- | # | ||
- | # id: 3000 - 4999 | ||
- | |||
- | #SecAction " | ||
- | </ | ||
- | - <code - MM-postCRS.conf> | ||
- | # | ||
- | # ModSecurity postload omitting signatures for OWASP CRS | ||
- | # | ||
- | # id: 5000 - 6999 | ||
- | |||
- | #SecAction " | ||
</ | </ | ||
- | - <code - MM-postLocal.conf> | + | - <code - MM-postLoad.conf> |
# | # | ||
- | # ModSecurity postload | + | # ModSecurity postload |
# | # | ||
- | # id: 7000 - 8999 | ||
- | #SecAction " | + | #SecRuleRemoveById 900000 |
</ | </ | ||
これで、MonitorMode WAFの設定ファイルが完成。 | これで、MonitorMode WAFの設定ファイルが完成。 | ||
- | |||
=== DropModeWAF === | === DropModeWAF === | ||
- 次にDropMode WAFを構築する。 | - 次にDropMode WAFを構築する。 | ||
行 699: | 行 732: | ||
これで、DropMode WAFの構築も終了。 | これで、DropMode WAFの構築も終了。 | ||
- | <WRAP info> | + | < |
なお、実際には、MonitorModeは検出のみだから全Signatureを利用していても性能が劣化する程度で済むことが多いが、DropModeの場合は、preLoadやPostloadの設定で、不要なSignatureをOffにする、もしくは重みつけを0にする必要があることに注意。 | なお、実際には、MonitorModeは検出のみだから全Signatureを利用していても性能が劣化する程度で済むことが多いが、DropModeの場合は、preLoadやPostloadの設定で、不要なSignatureをOffにする、もしくは重みつけを0にする必要があることに注意。 | ||
- | preCRSやPostCRSを作成してあるのはそのため。 | + | preLoadやPostLoadを作成してあるのはそのため。 |
</ | </ | ||
行 827: | 行 860: | ||
# ID | # ID | ||
- | # 1000-2999: Preload | + | # 1000-1999: Preload |
- | # 3000-4999: Preload | + | # 2000-3999: Reserve |
- | # 5000-6999: Postload ommiting signature list of OWASP CRS | + | # 4000-4999: Preload |
- | # 7000-8999: | + | # 5000-5999: Preload for OWASP CRS |
+ | # 6000-7999: Reserve | ||
+ | # 8000-8999: | ||
# 10000-10999: | # 10000-10999: | ||
# 11000-11999: | # 11000-11999: | ||
行 975: | 行 1010: | ||
xxxx/xx/xx xx:xx:xx [info] 3985# | xxxx/xx/xx xx:xx:xx [info] 3985# | ||
- | xxxx/xx/xx 15:11:31 [warn] 3985# | + | xxxx/xx/xx 15:11:31 [warn] 3985# |
# OWASP CRS検出分(union+select) | # OWASP CRS検出分(union+select) | ||
行 982: | 行 1017: | ||
xxxx/xx/xx xx:xx:xx [info] 3985# | xxxx/xx/xx xx:xx:xx [info] 3985# | ||
- | xxxx/xx/xx xx:xx:xx [warn] 3985# | + | xxxx/xx/xx xx:xx:xx [warn] 3985# |
xxxx/xx/xx xx:xx:xx [info] 3985# | xxxx/xx/xx xx:xx:xx [info] 3985# | ||
</ | </ | ||
- | |||
==== Monitor Modeの検証 ==== | ==== Monitor Modeの検証 ==== | ||
networkapp/waf/mod-security.txt · 最終更新: 2018/11/14 17:00 by seirios