-
Notifications
You must be signed in to change notification settings - Fork 1.6k
ModSecurity not putting some transactions to audit log #2693
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
@PeterP55P check directive "SecAuditLog" in your modsecurity.conf, in file this directive must to have all content from match rules. In logger error normally show only wich generate action the lock. |
I'm not really sure what do you mean. The directive "SecAuditLog" points to the path of the audit log file which is set and some transactions are being captured there. The problem is that many others are not captured in this file. |
Hello @PeterP55P, To summarize your issue:
One way that could happen is if you have set A related way to see this effect is you are using the Beyond that, I would suggest seeing what is happening by checking ModSecurity's DebugLog (level 9). |
@PeterP55P do you use ModSecurity-nginx with |
@liudongmiao very good point. thanks for this finding. this is exactly our problem. after commenting out the |
Hi - i have this exact problem also. In my case, I'm using My config is otherwise the same as @PeterP55P except i have not configured any nginx.ingress.kubernetes.io/modsecurity-snippet: |
SecRuleEngine On
SecDebugLog /var/log/nginx/error.log
SecAuditLogType Serial
SecAuditLog /var/log/nginx/error.log When I trigger a rule, I can indeed see a log indicating the error but showing only rule
Any help greatly appreciated! |
Hello @byrneo , I believe what you are describing is quite different from what is otherwise discussed here. There are three different log files relevant to ModSecurity: (1) the web server's own 'error.log' file, (2) ModSecurity's own audit log file and (3) ModSecurity's debug log. It's not usual (and probably not advisable) to combine these in a single physical file, as your configuration snippet suggests you have done. If only nginx's own web server logging goes to /var/log/nginx/error.log, and you are using CRS's anomaly scoring mode, then, yes under certain configurations, you might only see the rule that actually resulted in the 'deny' action (949110 in your case). However, you should able to get additional rule information to show up there by adjusting the setting for 'error_log' (this may be in your nginx.conf file) to be 'info'. |
Thanks for the feedback @martinhsv ! Reason for the aggregated logs is because I have log monitoring already in place on the cluster and all logs that are sent to So, within the ingress-nginx pods, there are already default symlinks such as:
and i've also tried setting That said, I think you are right: my issue is likely different as i have just noticed that many log files do indeed always appear in Thanks for the pointers |
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.
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 parameter5' 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):
Rule Set (please complete the following information):
The text was updated successfully, but these errors were encountered: