首页 > 其他分享 >modsecurity: 规则的体系三

modsecurity: 规则的体系三

时间:2024-10-21 14:58:34浏览次数:7  
标签:体系 CRS level rules REQUEST modsecurity paranoia 规则 OWASP

一,modsecurity规则的级别:paranoia level

modsecurity根据规则可能存在的误报情况,设置了规则的级别,称之为PL(paranoia level),
共有4个级别,分别为1/2/3/4,
级别越高,漏报越少,误报越多。
用户可以根据实际业务情况适当调整,
默认设置PL=1,可以在crs-setup.conf中设置

配置文件:

crs-setup.conf

默认的设置:

#
# -- [[ Paranoia Level Initialization ]] ---------------------------------------
#
# The Paranoia Level (PL) setting allows you to choose the desired level
# of rule checks that will add to your anomaly scores.
#
# With each paranoia level increase, the CRS enables additional rules
# giving you a higher level of security. However, higher paranoia levels
# also increase the possibility of blocking some legitimate traffic due to
# false alarms (also named false positives or FPs). If you use higher
# paranoia levels, it is likely that you will need to add some exclusion
# rules for certain requests and applications receiving complex input.
#
# - A paranoia level of 1 is default. In this level, most core rules
#   are enabled. PL1 is advised for beginners, installations
#   covering many different sites and applications, and for setups
#   with standard security requirements.
#   At PL1 you should face FPs rarely. If you encounter FPs, please
#   open an issue on the CRS GitHub site and don't forget to attach your
#   complete Audit Log record for the request with the issue.
# - Paranoia level 2 includes many extra rules, for instance enabling
#   many regexp-based SQL and XSS injection protections, and adding
#   extra keywords checked for code injections. PL2 is advised
#   for moderate to experienced users desiring more complete coverage
#   and for installations with elevated security requirements.
#   PL2 comes with some FPs which you need to handle.
# - Paranoia level 3 enables more rules and keyword lists, and tweaks
#   limits on special characters used. PL3 is aimed at users experienced
#   at the handling of FPs and at installations with a high security
#   requirement.
# - Paranoia level 4 further restricts special characters.
#   The highest level is advised for experienced users protecting
#   installations with very high security requirements. Running PL4 will
#   likely produce a very high number of FPs which have to be
#   treated before the site can go productive.
#
# All rules will log their PL to the audit log;
# example: [tag "paranoia-level/2"]. This allows you to deduct from the
# audit log how the WAF behavior is affected by paranoia level.
#
# It is important to also look into the variable
# tx.enforce_bodyproc_urlencoded (Enforce Body Processor URLENCODED)
# defined below. Enabling it closes a possible bypass of CRS.
#
# Uncomment this rule to change the default:
#
#SecAction \
#    "id:900000,\
#    phase:1,\
#    pass,\
#    t:none,\
#    nolog,\
#    tag:'OWASP_CRS',\
#    ver:'OWASP_CRS/4.8.0-dev',\
#    setvar:tx.blocking_paranoia_level=1"


# It is possible to execute rules from a higher paranoia level but not include
# them in the anomaly scoring. This allows you to take a well-tuned system on
# paranoia level 1 and add rules from paranoia level 2 without having to fear
# the new rules would lead to false positives that raise your score above the
# threshold.
# This optional feature is enabled by uncommenting the following rule and
# setting the tx.detection_paranoia_level.
# Technically, rules up to the level defined in tx.detection_paranoia_level
# will be executed, but only the rules up to tx.blocking_paranoia_level affect the
# anomaly scores.
# By default, tx.detection_paranoia_level is set to tx.blocking_paranoia_level.
# tx.detection_paranoia_level must not be lower than tx.blocking_paranoia_level.
#
# Please notice that setting tx.detection_paranoia_level to a higher paranoia
# level results in a performance impact that is equally high as setting
# tx.blocking_paranoia_level to said level.
#
#SecAction \
#    "id:900001,\
#    phase:1,\
#    pass,\
#    t:none,\
#    nolog,\
#    tag:'OWASP_CRS',\
#    ver:'OWASP_CRS/4.8.0-dev',\
#    setvar:tx.detection_paranoia_level=1" 

 

二,规则的级别设置方式:

其规则的分级方式也很特别,是通过在规则文件中的位置进行的分级,下面简化下分级规则设置方法

级别规则设置方法:skipAfter和SecMarker

skipAfter:条件达成,跳到下个标记点

SecMarker:规则标记点

看一下规则设置的例子:

rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf:SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 1" "id:920011,phase:1,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.8.0-dev',skipAfter:END-REQUEST-920-PROTOCOL-ENFORCEMENT"
rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf:SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 1" "id:920012,phase:2,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.8.0-dev',skipAfter:END-REQUEST-920-PROTOCOL-ENFORCEMENT"
rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf:SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 2" "id:920013,phase:1,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.8.0-dev',skipAfter:END-REQUEST-920-PROTOCOL-ENFORCEMENT"
rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf:SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 2" "id:920014,phase:2,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.8.0-dev',skipAfter:END-REQUEST-920-PROTOCOL-ENFORCEMENT"
rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf:SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 3" "id:920015,phase:1,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.8.0-dev',skipAfter:END-REQUEST-920-PROTOCOL-ENFORCEMENT"
rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf:SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 3" "id:920016,phase:2,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.8.0-dev',skipAfter:END-REQUEST-920-PROTOCOL-ENFORCEMENT"
rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf:SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 4" "id:920017,phase:1,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.8.0-dev',skipAfter:END-REQUEST-920-PROTOCOL-ENFORCEMENT"
rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf:SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 4" "id:920018,phase:2,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.8.0-dev',skipAfter:END-REQUEST-920-PROTOCOL-ENFORCEMENT"
rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf:SecMarker "END-REQUEST-920-PROTOCOL-ENFORCEMENT"

 

标签:体系,CRS,level,rules,REQUEST,modsecurity,paranoia,规则,OWASP
From: https://www.cnblogs.com/architectforest/p/18489494

相关文章

  • 我在大厂做 CR——如何体系化防控空指针异常gj
    合集-卓越工程(4)1.为什么需要依赖注入10-072.我在大厂做CR——为什么建议使用枚举来替换布尔值10-163.我在大厂做CR——如何体系化防控空指针异常10-214.我在大厂做CR——再谈如何优雅修改代码10-07收起阅读目录什么是空指针异常CR我们要做什么再谈空指针防控手段写在......
  • modsecurity: 规则的体系一
    一,每个事务的生命周期:如图:每个事务在modsecurity需要经历5个阶段,在每个阶段可能需要解析等操作,然后调用相应阶段的规则进行匹配,对应规则中的phase阶段一:requestheaders请求头,这是modsecurity最先接触到的数据,      需要验证请求头相关的规则,并根据请求头来判断......
  • 计算机体系结构中的总线带宽计算知识点
    这道错题考查的是计算机体系结构中的总线带宽计算知识点。总线带宽是指单位时间内总线上可以传输的数据量,它是衡量总线性能的一个重要参数。总线带宽的计算涉及到总线宽度和总线频率两个关键因素。总线宽度总线宽度,也称为数据路径宽度,是指总线一次能够传输的数据位数。例如,32位......
  • [实时计算flink]动态CEP中规则的JSON格式定义
    本文为您介绍CEP中规则的JSON格式相关信息。目标人群客户风控平台开发人员:对FlinkCEP较熟悉的平台研发人员应能快速学习本格式,并根据自身平台需求判断是否需要进一步封装。客户风控策略人员:只熟悉具体策略但缺乏Java经验的同学,在熟悉CEP概念的基础上,也可快速上手本格式的使......
  • PCB电路设计的让你少走弯路的经验规则
    在PCB设计中,为了确保信号的稳定性和减少干扰,遵循一系列设计原则至关重要。以下是对您提供的文章内容的优化和修改,以保持原创性并避免与现有资料重复:1.最小化回路面积原则-为了降低信号的辐射和提高抗干扰能力,应尽可能减小信号线与其回路构成的环面积。在地平面分割时,应......
  • 【关联规则挖掘算法‌】基于兴趣度的关联规则挖掘算法
    目录一、基于兴趣度的关联规则挖掘算法概述1.1兴趣度度量1.2基于兴趣度的关联规则挖掘算法1.2.1支持度-置信度(SC)算法1.2.2支持度-提升度(SP)算法1.2.3支持度-互信息(SM)算法1.2.4基于兴趣度的关联规则挖掘算法二、基于兴趣度的关联规则挖掘算法优缺点和改进2.1  ......
  • 【关联规则挖掘算法‌】基于约束的关联规则挖掘算法
    目录一、基于约束的关联规则挖掘算法概述二、基于约束的关联规则挖掘算法优缺点和改进2.1  基于约束的关联规则挖掘算法优点2.2  基于约束的关联规则挖掘算法缺点2.3  基于约束的关联规则挖掘算法改进三、 基于约束的关联规则挖掘算法编程实现3.1  基于约束的......
  • 新书图阁ptcms小说源码(附带最新4个可用采集规则)
    源码简介新书图阁小说源码ptcms(附带最新4个可用ptcms采集规则),自己花了点时间研究了下采集,写了4个可直接使用的采集规则,推荐采集时配合socks5代理一起使用。全新开发,新版UI,添加原创专区,新闻发布,书单发布,采集日志,百度推送,神马推送,推送日志功能。前端高仿起点小说网,自适应模......
  • 【CSS in Depth 2 精译_052】第三部分:现代 CSS 代码组织 + 第 8 章:概述层叠图层及其嵌
    当前内容所在位置(可进入专栏查看其他译好的章节内容)【第三部分现代CSS代码组织】✔️【第八章层叠图层及其嵌套】✔️8.1用layer图层来操控层叠规则(上篇)✔️8.1.1图层的定义(上篇)✔️8.1.2图层的顺序与优先级(精译中⏳)8.1.3revert-layer关键字文......
  • HarmonyOS的连接艺术之六: 使用 Deep Linking,灵活定义链接规则
    本文旨在深入探讨华为鸿蒙HarmonyOSNext系统(截止目前API12)的技术细节,基于实际开发实践进行总结。主要作为技术分享与交流载体,难免错漏,欢迎各位同仁提出宝贵意见和问题,以便共同进步。本文为原创内容,任何形式的转载必须注明出处及原作者。DeepLinking是一种基于URL链接的......