-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Question about the audit log when RelevantOnly is specified #2637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Also, saving messages is disabled here: Other confusing thing follows from the doc:
but it seems that the current implementation provides for disabling logging in any case, even when another rule matches. |
Hello @AirisX , It is possible that I'm not fully understanding the nature of your concern/inquiry. However, one thing to clarify immediately is that using something like ...
... does not literally mean to only write to the audit log when the HTTP response code returned to the client matches the specified regex. If we were to be that restrictive in terms of audit log writing, we would break the DetectionOnly functionality. With DetectionOnly we explicitly do not want to interfere with clients' getting web-server-generated responses, so they will receive a response code of 200. However, that does not mean we want to omit logging suspicious content (say SQLi) that has triggered one of our rules. Note that a default assumption of 'auditlog' is explicitly mentioned in the v2 Reference Manual (granted, the v2 manual will occasionally differ from how v3 works): "Additionally, the auditlog action is present by default in rules, this will make the engine bypass the 'SecAuditLogRelevantStatus' and send rule matches to the audit log regardless of status. You must specify noauditlog in the rules manually or set it in SecDefaultAction." |
Hello @martinhsv , Thanks for answering. I had to mention, that I'm using As for:
You do not find that this is fundamentally contrary to the essence of the |
Hello @martinhsv , I also added some regression test cases (noauditlog-relevant.json). Before the changes, cases 1 and 4 did not work. Now they work:
|
Hello @AirisX , I agree that the audit logging behaviour is less clear than it could be. In particular, the names of the two cited configuration items can be easy to misinterpret as to their effect. That aside, I'm not convinced that the current functionality is fundamentally problematic in the way that you suggest. You write:
Again, the naming of those configuration items may lead one to that conclusion, but that is a mistake. Leave aside the names for a moment and consider the underlying motivation for the configuration items (and here I am in part interpreting my predecessors' thinking): There are three high level options for the question 'Should logging to the audit log occur?': 1) Yes, for every request 2) No, never 3) Yes, but only for 'interesting things'. For 'interesting things', why have an extra configuration item such as SecAuditLogRelevantStatus? Why not simply allow the internal logic of ModSecurity (a rule has detected) and a rule's associated actions (especially the logging actions: log,nolog,auditlog,noauditlog) to make the determination? One answer is that it allows one to categorize requests as 'interesting things', and thus worth audit logging, even if no ModSecurity rules are triggered at all. It is reasonable to think of certain types of response codes generated by the web server to be of interest in having an overall view of possible attacks. In other words, 'SecAuditLogRelevantStatus' is not properly understood as a full and complete definition of what is meant by 'Relevant' in 'SecAuditEngine RelevantOnly'. Rather, it defines a set of status codes that make a request an 'interesting thing' (i.e. Relevant) in addition to other factors that may independently do that. I'll also reiterate my earlier point about DetectionOnly. Even though that is not the setting you are using, we still need to consider it. Your pull request will break that functionality. With your pull request, DetectionOnly, and a simple rule like ...
... even if the rule triggers, no information will be written to the audit log. |
Hello @martinhsv , I checked the next case (with DetectionOnly specified) and it really doesn't work:
But if DetectionOnly is the only one stumbling stone, what if we explicitly handle it here like this:
In this case, all test cases work fine:
The rest of the behavior, that this PR brings, also looks harmonious in relation to the current implementation. |
Maybe there are other pitfalls to consider? |
Hi @AirisX , I'm going to go ahead and close this since it seems we have adequately clarified the misconception at the heart of this issue's creation: namely, that SecAuditLogRelevantStatus is not intended to be (and indeed cannot ever be) a full and complete definition of the 'Relevant' in 'SecAuditEngine RelevantOnly' I'm not at all clear what you are hoping to achieve with your more recent posting. If you think you have an important use case that cannot be reasonably addressed using existing ModSecurity controls, please feel free to open a fresh issue. If you do so, please provide as much detail as possible as to the scenario being addressed and why other tools (such as the nolog and noauditlog actions) are insufficient. |
Hello, @zimmerle.
https://github.com/SpiderLabs/ModSecurity/blob/ec86b242e15f9df1d143c1b7f86a27889658b4cb/src/audit_log/audit_log.cc#L299-L302
I have some doubts about the correct handling of the "noauditlog" action in "saveIfRelevant".
In my case I defined next config with the relevant statuses and the only one non disruptive rule for simplifying (other setting is omitted). Pay attention that I am not using "nouauditlog" in the rule:
Then I send the request without the "Accept" header. Eventually I get an audit log record with a 200 status code, although it's not the relevant status.
Debug log:
Could you please help to inspect this case?
The text was updated successfully, but these errors were encountered: