ModSecurity - 在 SecRule 上设置 nolog 时审核日志条目
ModSecurity - audit log entries while nolog set at SecRule
我正在寻求有关 modsecurity 配置问题的帮助。
我们最近发现我们的 modsecurity 配置并不像我们想象的那样运行,
特别是为所有调用生成 modsecurity 审计日志,
而我们在 SecRule 条目中设置了 nolog 参数。
所以举个例子:
SecAuditEngine RelevantOnly
SecAuditLogRelevantStatus ^5
SecDefaultAction log,auditlog,deny,status:403,phase:2,t:lowercase,t:replaceNulls,t:compressWhitespace
SecRule REQUEST_FILENAME "^/application(/.*)?$" phase:2,chain,t:none,allow,nolog
SecRule REQUEST_METHOD (?i)^(GET|POST|HEAD)$
SecAction block
与此条目匹配的请求的预期是不会对错误日志或审核日志产生任何日志条目。
实际结果是错误日志确实是空的,但是审计日志被填满了。
在审计日志中,我们可以确认请求是(在B块中):
GET /application/that/does/something?and=has&some=parameters
我们也可以确认引用的SecRule是匹配的,如果我们删除它,请求被认为是禁止的。
我们想要实现的目标:匹配规则的审核日志中没有条目
在此先感谢您提供的任何帮助
注意:在下面的讨论后根据原始答案进行编辑。
我最初认为这是由于 nolog 仅引用错误日志,但事实并非如此,我自己的测试已经证明了这一点,文档也显示了这一点,正如您在下面的评论中正确指出的那样(https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#nolog).
所以你正在做的事情应该有效。我无法重复这个问题,当我在 ModSecurity 2.9 上测试时,它正确地没有记录到任何一个日志。
Rule IDs 在 ModSecurity 2.7 中成为强制性的,你没有使用它们的事实表明你使用的是旧版本,所以我想知道这是否是一个从那时起修复的错误?更改日志 (https://github.com/SpiderLabs/ModSecurity/blob/master/CHANGES) 有几个可能与此相关的潜在修复:
2010 年 2 月 4 日修复 - 2.5.12:
Fixed nolog,auditlog/noauditlog/nolog controls for disruptive actions.
2006 年 11 月 15 日修复 - 2.0.4
Made "nolog" do what it is supposed to do - cause a rule match to
not be logged. Also "nolog" now implies "noauditlog" but it's
possible to follow "nolog" with "auditlog" and have the match
not logged to the error log but logged to the auditlog. (Not
something that strikes me as useful but it's possible.)
因此,如果您 运行 没有这个版本,这可能就是您所看到的原因。
我正在寻求有关 modsecurity 配置问题的帮助。 我们最近发现我们的 modsecurity 配置并不像我们想象的那样运行, 特别是为所有调用生成 modsecurity 审计日志, 而我们在 SecRule 条目中设置了 nolog 参数。
所以举个例子:
SecAuditEngine RelevantOnly
SecAuditLogRelevantStatus ^5
SecDefaultAction log,auditlog,deny,status:403,phase:2,t:lowercase,t:replaceNulls,t:compressWhitespace
SecRule REQUEST_FILENAME "^/application(/.*)?$" phase:2,chain,t:none,allow,nolog
SecRule REQUEST_METHOD (?i)^(GET|POST|HEAD)$
SecAction block
与此条目匹配的请求的预期是不会对错误日志或审核日志产生任何日志条目。 实际结果是错误日志确实是空的,但是审计日志被填满了。
在审计日志中,我们可以确认请求是(在B块中):
GET /application/that/does/something?and=has&some=parameters
我们也可以确认引用的SecRule是匹配的,如果我们删除它,请求被认为是禁止的。
我们想要实现的目标:匹配规则的审核日志中没有条目
在此先感谢您提供的任何帮助
注意:在下面的讨论后根据原始答案进行编辑。
我最初认为这是由于 nolog 仅引用错误日志,但事实并非如此,我自己的测试已经证明了这一点,文档也显示了这一点,正如您在下面的评论中正确指出的那样(https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#nolog).
所以你正在做的事情应该有效。我无法重复这个问题,当我在 ModSecurity 2.9 上测试时,它正确地没有记录到任何一个日志。
Rule IDs 在 ModSecurity 2.7 中成为强制性的,你没有使用它们的事实表明你使用的是旧版本,所以我想知道这是否是一个从那时起修复的错误?更改日志 (https://github.com/SpiderLabs/ModSecurity/blob/master/CHANGES) 有几个可能与此相关的潜在修复:
2010 年 2 月 4 日修复 - 2.5.12:
Fixed nolog,auditlog/noauditlog/nolog controls for disruptive actions.
2006 年 11 月 15 日修复 - 2.0.4
Made "nolog" do what it is supposed to do - cause a rule match to not be logged. Also "nolog" now implies "noauditlog" but it's possible to follow "nolog" with "auditlog" and have the match not logged to the error log but logged to the auditlog. (Not something that strikes me as useful but it's possible.)
因此,如果您 运行 没有这个版本,这可能就是您所看到的原因。