ModSecurity(mod_security) ã® Core Rule Set(CRS)ãèªã¿è§£ãããã®1ï¼global_config, configã
Apache ã¢ã¸ã¥ã¼ã«ã§ãã ModSecurity*1 ã® Core Rule Setï¼CRSï¼*2ã¨ãªã£ã¦ããã
- 確èªãããã¼ã¸ã§ã³
- modsecurity-crs v2.0.2ï¼2009å¹´10æ2æ¥ç¾å¨ï¼
CRS v2.0.2 ã® tar çããã¦ã³ãã¼ããå±éããã¨ã以ä¸ã®ãããªæ§æã¨ãªã£ã¦ããã解åãããã£ã¬ã¯ããªç´ä¸ã«ãããmodsecurity_crs_10_global_config.conf 㨠modsecurity_crs_10_config.conf ã® 2 ã¤ã®ãã¡ã¤ã«ããModSecurityå ¨ä½ã®è¨å®ãã¡ã¤ã«ã¨ãªãããã®æ¥è¨ã§ã¯ããã® 2 ã¤ã® conf ãã¡ã¤ã«ã ModSecurity Reference Manual*3 ãåºã«èªã¿è§£ãã¦ã¿ãã
# tar xzvf modsecurity-crs_2.0.2.tar.gz # cd modsecurity-crs_2.0.2 # ls -1R .: CHANGELOG LICENSE README base_rules modsecurity_crs_10_config.conf modsecurity_crs_10_global_config.conf optional_rules util ./base_rules: modsecurity_40_generic_attacks.data modsecurity_41_sql_injection_attacks.data modsecurity_46_et_sql_injection.data modsecurity_46_et_web_rules.data modsecurity_50_outbound.data modsecurity_crs_20_protocol_violations.conf modsecurity_crs_21_protocol_anomalies.conf modsecurity_crs_23_request_limits.conf modsecurity_crs_30_http_policy.conf modsecurity_crs_35_bad_robots.conf modsecurity_crs_40_generic_attacks.conf modsecurity_crs_41_phpids_filters.conf modsecurity_crs_41_sql_injection_attacks.conf modsecurity_crs_41_xss_attacks.conf modsecurity_crs_45_trojans.conf modsecurity_crs_46_et_sql_injection.conf modsecurity_crs_46_et_web_rules.conf modsecurity_crs_47_common_exceptions.conf modsecurity_crs_48_local_exceptions.conf modsecurity_crs_49_enforcement.conf modsecurity_crs_50_outbound.conf modsecurity_crs_60_correlation.conf ./optional_rules: modsecurity_crs_20_protocol_violations.conf modsecurity_crs_21_protocol_anomalies.conf modsecurity_crs_40_generic_attacks.conf modsecurity_crs_42_comment_spam.conf modsecurity_crs_42_tight_security.conf modsecurity_crs_55_marketing.conf ./util: httpd-guardian.pl modsec-clamscan.pl runav.pl
modsecurity_crs_10_global_config.conf
ModSecurity å ¨ä½ã«é¢é£ããè¨å®ã 5 ã¤å®ç¾©ããã¦ãããã¡ãªã¿ã«ããã§ã®è¨å®å¤ã¯ CRS ã®åæå¤ã§ããã
### HTTP ã¬ã¹ãã³ã¹ã® Server ãããã®å¤æ´ # åæå¤ã®ã¾ã¾ã ã¨ãServer ããããã®ãã®ãåºåãããªã # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N10BEE SecServerSignature " " ### ModSecurity æ¤ç¥ã«ã¼ã«ã®ã·ã°ããã£ï¼ãããã¯ç¨ï¼ # ModSecurity ã® Audit Log ã«åºåããã # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N104DA SecComponentSignature "core ruleset/2.0.2" ### POST ãªã¯ã¨ã¹ãã§éä¿¡ããã form ãã¼ã¿ã®åå²æåã®å®ç¾© # é常ã¯ã&ããªã®ã§ãç¹ã«å¤æ´ããå¿ è¦ãªã # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N101DE SecArgumentSeparator "&" ### initcol ã¢ã¯ã·ã§ã³ã§å®ç¾©ãããã¼ã¿ã®ä¿åãã£ã¬ã¯ããªã®å®ç¾© # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N10566 SecDataDir /tmp ### å¿ ãå®è¡ããã Action ã®å®ç¾© # Apache ã HTTP ãªã¯ã¨ã¹ãããããèªã¿åã£ã段éã§å®è¡ãããï¼phase:1ï¼ # global, å¤æ° remote_addr ãä¿åããããããããããã¥ã¡ã³ãã«å¤§ããæ å ±ããªã㪠# initcol # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N11847 # SecAction # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N101AD SecAction "phase:1,t:none,pass,nolog,initcol:global=global,initcol:ip=%{remote_addr}"
modsecurity_crs_10_config.conf
詳細ãªModSecurity ã«é¢é£ããè¨å®ã 24 å®ç¾©ããã¦ãããã¡ãªã¿ã«ããã§ã®è¨å®å¤ã¯ CRS ã®åæå¤ã§ããã
## -- Configuration ---------------------------------------------------------- ### ModSecurity ã® Rule ã¨ã³ã¸ã³ã®åä½è¨å® # On = Rule ã¨ã³ã¸ã³ã®æå¹å # Off = Rule ã¨ã³ã¸ã³ã®ç¡å¹å # DetectionOnly = Rule ã¨ã³ã¸ã³ã®æå¹åï¼Request, Response ã® intercept ãªãï¼ # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N10AD4 SecRuleEngine On ### HTTP ãªã¯ã¨ã¹ãã»ããã£æ¤æ»è¨å® # ãã®è¨å®ãæå¹ã«ãããã¨ã§ãRule ã«ã¦ POST_PAYLOADãREQUEST_BODY å¤æ°ãæå®ã§ãã # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N107D5 SecRequestBodyAccess On ### HTTP ã¬ã¹ãã³ã¹ã»ããã£æ¤æ»è¨å® # ãã®è¨å®ãæå¹ã«ãããã¨ã§ãRule ã«ã¦ RESPONSE_BODY å¤æ°ãæå®ã§ãã # ãã ãæå¹ã«ããã¨ãã¦ãããããã¡ãªã³ã°å¯¾è±¡ã§ãããSecResponseBodyMimeType 㧠# æå®ãã MIME ã¿ã¤ããããHTTP ã¬ã¹ãã³ã¹ã»ããã£ãæ¤æ»ã§ããªã # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N1094B SecResponseBodyAccess On ### ãããã¡ãªã³ã°ãã HTTP ã¬ã¹ãã³ã¹ ã® MIME ã¿ã¤ãã®æå® # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N108E4 SecResponseBodyMimeType (null) text/html text/plain text/xml ### ãããã¡ãªã³ã°ãã HTTP ã¬ã¹ãã³ã¹ã®ä¸éãã¤ãå¤ # ãã®ä¸éå¤ä»¥ä¸ã® HTTP ã¬ã¹ãã³ã¹ããããã¡ãªã³ã°ãããã¨ããã¨ã # SecResponseBodyLimitAction ã§æå®ããã¢ã¯ã·ã§ã³ãå®è¡ãã模æ§ã # ãã¼ãã¦ã§ã¢ã³ã¼ãã£ã³ã°ã«ãããä¸éå¤ã¯ 1GBã # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N1088D SecResponseBodyLimit 524288 ### ãããã¡ãªã³ã°ä¸éå¤ä»¥ä¸ã® HTTP ã¬ã¹ãã³ã¹ãåä¿¡ããæã®å¦ç # RejectãProcessPartial ã«é¢ãã¦ãããã¥ã¡ã³ãã«å¤§ããè¨è¿°ããªãã # SecResponseBodyLimitAction ã® description ãèªãéãã§ã¯ã以ä¸ã¨æ¨æ¸¬ã # Reject = 500 Internal Server Error ãçºçãããReject ãã # ProcessPartial = SecResponseBodyLimit ã§æå®ããå¤ã¾ã§æ¤æ»ãã # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N108B9 SecResponseBodyLimitAction ProcessPartial ### HTTP ãªã¯ã¨ã¹ãå¦çæã«ããã XML ããã»ããµã®æå¹å # Content-Type: text/xml ã®å ´åã®ã¿ãXML ããã»ããµãæå¹ã«ãã # åæè¨å®ã§ã¯ã³ã¡ã³ãã¢ã¦ãããã¦ãããããç¡å¹ # ctl # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N116EB #SecRule REQUEST_HEADERS:Content-Type "text/xml" \ #"phase:1,pass,nolog,ctl:requestBodyProcessor=XML" ### Rule ã®ããã©ã«ãã¢ã¯ã·ã§ã³ã®è¨å® # SecRule ã«ã¦ Action ãä½ãå®ç¾©ããã¦ããªãã£ãå ´åã« # è¨å®ãããããã©ã«ãã¢ã¯ã·ã§ã³ã®å®ç¾© # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N10610 SecDefaultAction "phase:2,pass" ## -- File uploads configuration ----------------------------------------------- ### intercept ããããã¡ã¤ã«ã®ä¿åå ãã£ã¬ã¯ããªã®å®ç¾© # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N10C3C SecUploadDir /tmp ### intercept ãããã¡ã¤ã«åé¤ã®å®ç¾© # ModSecurity 㧠HTTP ãã©ã³ã¶ã¯ã·ã§ã³ã®æ¤æ»ãå®äºããå¾ã§ã # intercept ãããã¡ã¤ã«ãåé¤ãããå¦ããå®ç¾©ãã # On = åé¤ããªã # Off = åé¤ãã # RelevantOnly = é¢é£ãªããå¤æãããï¼Rule ã«ä¸è´ããªãï¼ï¼ãã¡ã¤ã«ã®ã¿åé¤ãã # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N10C95 SecUploadKeepFiles Off ### ã¢ãããã¼ããã¡ã¤ã«ã®æ¤æ» Rule # ã¢ãããã¼ãããããã¡ã¤ã«ãå¤é¨ã¹ã¯ãªããã§æ¤æ»ãã Rule # åæè¨å®ã§ã¯ã³ã¡ã³ãã¢ã¦ãããã¦ãããããç¡å¹ # inspectFile # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N11C5B # SecRule FILES_TMPNAMES "@inspectFile /opt/apache/bin/inspect_script.pl" \ # "t:none" ## -- Logging ---------------------------------------------------------------- ### ModSecurity audit logging engine ã®è¨å® # audit log ã«è¨é²ãã HTTP ãã©ã³ã¶ã¯ã·ã§ã³ãè¨å®ãã # On = ãã¹ã¦ã® HTTP ãã©ã³ã¶ã¯ã·ã§ã³ã audit log ã«è¨é²ãã # Off = ãã¹ã¦ã® HTTP ãã©ã³ã¶ã¯ã·ã§ã³ã audit log ã«è¨é²ããªã # RelevantOnly = è¦åãã¨ã©ã¼ã¨ãªã£ã HTTP ãã©ã³ã¶ã¯ã·ã§ã³ã # SecAuditLogRelevantStatus ã§å®ç¾©ãã HTTP ãã©ã³ã¶ã¯ã·ã§ã³ã®ã¿ # audit log ã«è¨é²ãã # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N10213 SecAuditEngine RelevantOnly ### audit log ãè¨é²ãã HTTP ã¬ã¹ãã³ã¹ã»ã¹ãã¼ã¿ã¹ã®å®ç¾© # SecAuditEngine RelevantOnly ã®å ´åãããã§å®ç¾©ãã # ã¹ãã¼ã¿ã¹ã³ã¼ãã«åè´ãã HTTP ãã©ã³ã¶ã¯ã·ã§ã³ã®ã¿ # audit log ã«è¨é²ãã # åæå¤ï¼404 ãé¤ã 4xxãããã³ 5xx # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N103B1 SecAuditLogRelevantStatus "^(?:5|4(?!04))" ### audit log ã®ä¿åå½¢å¼ã®å®ç¾© # Serial = ãã¹ã¦ã® audit log entry ã 1 ã¤ã®ãã¡ã¤ã«ã«ä¿åãã # Concurrent = audit log entry ãããããå¥ã®ãã¡ã¤ã«ã«ä¿åãã # SecAuditLogStorageDir ã«ã¦ãä¿åå ãã£ã¬ã¯ããªã®æå®ãå¿ è¦ # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N1040B SecAuditLogType Serial ### audit log ã®ã¡ã¤ã³ãã¡ã¤ã«ã®å®ç¾© # SecAuditLogType Serial ã®å ´åããã¹ã¦ã® audit log ã®ä¿åå # SecAuditLogType Concurrent ã®å ´åãåãã¡ã¤ã«ã® Index æ å ±ãä¿åãããæ¨¡æ§ # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N10260 SecAuditLog logs/modsec_audit.log ### audit log ã®ä¿åå ãã£ã¬ã¯ããªã®å®ç¾© # SecAuditLogType Concurrent ã®åãã¡ã¤ã«ãä¿åãããã£ã¬ã¯ã㪠# åæè¨å®ã§ã¯ã³ã¡ã³ãã¢ã¦ãããã¦ãããããç¡å¹ # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N103E2 # SecAuditLogStorageDir logs/modsec_audit ### audit log entry ã®å®ç¾© # audit log ã«è¨é²ãã entry ãå®ç¾©ããã # å entry ã¯ã¢ã«ãã¡ãããã«å¯¾å¿ãã¦ããã # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N1031E SecAuditLogParts "ABIFHKZ" ### ããã©ã¼ãã³ã¹æ¸¬å®ç®çã®ãã°ãã¡ã¤ã«ã®å®ç¾© # LogFormatãCustomLog ã¯ãããã Apache ã§å®ç¾©ããã¦ãããã£ã¬ã¯ãã£ã # http://www.modsecurity.org/documentation/modsecurity-apache/1.9.3/html-multipage/06-special_features.html # Performance measurement ãåç § # åæè¨å®ã§ã¯ã³ã¡ã³ãã¢ã¦ãããã¦ãããããç¡å¹ # # 以ä¸ãApache HTTP ãµã¼ã ãã¼ã¸ã§ã³ 2.2 ã®ããã¥ã¡ã³ã # LogFormat ãã£ã¬ã¯ãã£ã # http://httpd.apache.org/docs/2.2/ja/mod/mod_log_config.html#logformat # CustomLog ãã£ã¬ã¯ãã£ã # http://httpd.apache.org/docs/2.2/ja/mod/mod_log_config.html#customlog # # LogFormat "%V %h %t %{UNIQUE_ID}e \"%r\" %>s %X | %I %O | %<{mod_security-time1}n %<{mod_security-time2}n %<{mod_security-time3}n %D" mperformance # CustomLog logs/modsec_performance.log mperformance ## -- Tuning and debugging --------------------------------------------------- ### Cookie ãã©ã¼ãããã®å®ç¾© # 0: version 0 cookie(Netscape å½¢å¼) # 1: version 1(RFC2109 ã§å®ç¾©ããã¦ãããã¼ã¸ã§ã³ã¨æ¨æ¸¬) # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N10530 SecCookieFormat 0 ### ã¡ã¢ãªã«ä¿åãã HTTP ãªã¯ã¨ã¹ãã®ä¸éãã¤ãå¤ # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N10861 SecRequestBodyInMemoryLimit 131072 ### ModSecurity debug log ã®å®ç¾© # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N10589 SecDebugLog logs/modsec_debug.log ### ModSecurity debug log ã«è¨é²ãããã°ã¬ãã«ã®å®ç¾© # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N105B0 SecDebugLogLevel 3 ### ä¸æãã¡ã¤ã«ã®ä¿åå ãã£ã¬ã¯ããªã®å®ç¾© # http://www.modsecurity.org/documentation/modsecurity-apache/2.5.10/modsecurity2-apache-reference.html#N10C15 SecTmpDir /tmp
ãåéç¨ã¡ã¼ã«ã¢ãã¬ã¹ãï¼q1w2e3w2@gmail.com