-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Msg/Logdata block misrepresented in JSON audit log matched_rules block #1174
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
@dune73 do you have any other rules that are matching when this audit log entry is written? I ask because at initial glance I would guess this is happening because macro expansion of msg and logdata is occurring when The second entry you attached is an Apache error log entry, not an audit log entry. When an alert is written to the error log, Perhaps something to take away from this is that macro expansion of individual rules in JSON is of limited value because of this behavior. |
Thank you for your explanation @p0pr0ck5. I think I understand why this happens. But I think it is not useable the way it is: Config:
Call:
Native Audit Log:
JSON Audit Log:
Matched_rules looks like Native Part K, then you give the unparsed rule correctly and then I have the messages correctly expanded (and partially escaped) in audit_data->messages that looks I see a quick fix by removing msg and data from the expanded rules in matched_rules the they are |
I do believe that removing So you think we should add another pair of keys in An alternative for now is to create separate variables in the |
I am skeptical of pushing more into additional variables. But maybe you can extract out of the data structure you need for audit_data. As the audit log is written in a single batch, that stuff must still be around. |
That's what I'm saying though, if you overwrite a variable, it's previous value isn't stored anywhere. If we wanted to hold each macro-expanded msg and logdata entry throughout the lifetime of the transaction, created with the value of the associated variables at the time of the rule match (like Apache error logs are created), we'd have to create a new apr array to hold this data (and we'd essentially be duplicating the |
ACK |
Have we figured out the best approach here? |
I'd either leave it away for good or extract the info out of |
As I'll have a PR up to remove this flawed data next week. |
Fair with me. |
Writing macro-expanded strings to JSON elements during the post-logging phase can be misleading, because it's possible that variable contents (such as MATCHED_VAR) could have changed after the rule match, altering their expected contents. Writing macro-epanded audit data really only makes sense when the macros are expanded immediately following the rule match. See issue owasp-modsecurity#1174 for more details.
Sorry for the multiple posts on my fork, had to clean up my clone. #1190 has the fix to remove msg and logdata. I don't think removing tags is necessary even though they expand macros, because those macros often are not something like MATCHED_VAR which is likely to be stomped on. |
Writing macro-expanded strings to JSON elements during the post-logging phase can be misleading, because it's possible that variable contents (such as MATCHED_VAR) could have changed after the rule match, altering their expected contents. Writing macro-epanded audit data really only makes sense when the macros are expanded immediately following the rule match. See issue #1174 for more details.
Fixed. Further info at: #1190. |
The following rule:
Results in the following audit log block:
msg and logdata are obviously wrong.
If you look at the native alert, it is perfectly ok:
The text was updated successfully, but these errors were encountered: