Skip to content

ModSecurity not putting some transactions to audit log #2693

Closed
@PeterP55P

Description

@PeterP55P

Describe the bug

We are facing a problem when in certain cases ModSecurity is not tracking the blocking in the audit log despite we have set it as a default action and the rule is not having any logging property set. In the error log, we can see only the rule which was triggered due to the anomaly score has been reached but nothing about the rules which actually counted the score. In some other cases, this information is visible.

In modsecurity.conf we have logging of rules enabled

SecAuditLogParts ABCIJDFHKZ

In crs-setup.conf we have default logging set to capture everything in both error and audit log.

SecDefaultAction "phase:1,log,auditlog,pass"
SecDefaultAction "phase:2,log,auditlog,pass"

We have also tried other combinations like using this setup

SecDefaultAction "phase:2,pass, nolog,auditlog"

But nothing helped.

Logs and dumps

The only thing we can see in the log is this part from the error log and when we need more details we need to enable debug and redo the action. In the example below I have changed the IP addresses for security reasons.

2022/03/09 08:32:25 [error] 1149#1149: *13832 [client 1.1.1.1] ModSecurity: Access denied with code 403 (phase 2). Matched "Operator Ge' with parameter 5' against variable TX:ANOMALY_SCORE' (Value: 15' ) [file "/etc/nginx/owasp-modsecurity-crs/rules/REQUEST-949-BLOCKING-EVALUATION.conf"] [line "139"] [id "949110"] [rev ""] [msg "Inbound Anomaly Score Exceeded (Total Score: 15)"] [data ""] [severity "2"] [ver "OWASP_CRS/3.4.0-dev"] [maturity "0"] [accuracy "0"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-generic"] [hostname "10.1.0.1"] [uri "/favicon.ico"] [unique_id "1646811145"] [ref ""], client: 1.1.1.1, server: example.com, request: "GET /favicon.ico HTTP/1.1", host: "example.com", referrer: "http://example.com/?q=%22%3E%3Cscript%3Ealert(1)%3C/script%3E%27"

We need to find a way how to make sure every attempt will be logged into the audit log.

Thanks in advance for any help.

Peter

To Reproduce

Steps to reproduce the behavior:

We just ran the URL below to trigger some WAF rules.

http://example.com/?q=%22%3E%3Cscript%3Ealert(1)%3C/script%3E%27

Expected behavior

We expect that every threat will be captured in audit log which is not happening at this time. Only some are captured while many are not. We can see only rule 949110 in the log which is the very last one and missing those others which counted the anomaly score.

Server (please complete the following information):

  • ModSecurity version (and connector): [ModSecurity v3.0.6 ]
  • WebServer: [nginx-1.20.2]
  • OS (and distro): [Oracle Linux 7.9]

Rule Set (please complete the following information):

  • Running any public or commercial rule set? [e.g. SpiderLabs public rules]
  • What is the version number? [CRS v3.4.0dev]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions