-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Timezone is not included in the time_stamp field of audit log in JSON format #2340
Comments
Hi @yesjustyet , I can reproduce your findings. This may have been a simple oversight when the v3 version of the JSON logging was written, but it's also possible that it was an intentional decision for some reason. I will follow up. One alternative that might potentially be useful to you is to make use of the TIME_EPOCH variable. (E.g. an extra rule with an action like 'msg:"EpochTime %{TIME_EPOCH}'.) If it was a simple oversight, it will probably just get fixed. On the chance that it was intentional, however, would use of TIME_EPOCH meet your needs (in general and not just for the short term)? Thanks for raising this issue and for any feedback you may have. |
Hi @martinhsv , |
Hi! |
Hi @yesjustyet , No, I'm afraid there's no update. I agree that the TIME_EPOCH workaround is not going to be convenient for all deployments. If your ruleset is small, you could potentially add the extra output to each pre-existing message. Alternatively, if you're using something like CRS's anomaly scoring method, you could add the TIME_EPOCH output to the phase:5 rule that actually makes the decision to deny. But, yes, in at least some setups this is likely to be a burdensome workaround. If I think of any other suggestions in the near term I'll mention it. In the meantime, I'll add this item to our 3.1.1 list. |
The format should be ISO8601, please - the current format is not easy to parse |
Hi @tomsommer , In order to consider your request, it would probably be helpful to more fully describe what you mean. For example, what do you mean by "the current format is not easy to parse"? Are you referring to the current timestamp information that is already present in ModSecurity v3, regardless of the presence of time zone? In general, knowing what portions of 'ISO8601' that you believe to be relevant would be useful along with any examples of 'current' vs. your 'expected'. |
For me, it's hard to parse because it's not following any known valid standard format I can find. Now I have to figure out how to "hack" elasticsearch to parse dates with two spaces between the parts dynamically/self-conditionally. I will second the above, a standard ISO8601 would make a major difference for programmatic log analysis. Is there an official name/standard/format-definition for the date-format currently employed on audit logs? |
Exactly what @ensemblebd said |
I see. That's a fair bit different from this issue (about the lack of timezone) and probably warrants being in its own, separate issue. Would one of you like to go ahead and create one? |
Json format uses: Whereas the Old Audit Format uses: Humbly requesting that Json use the exact same as Old. So perhaps:
where
/src/audit_log/audit_log.cc
Then the seclang parser: /src/parser/seclang-parser.yy #781 (and I supose .cc needs all the line numbers transposed)
And a handful of other parser changes that are beyond my knowledge level. Symbol definition for Then we could all just simply do this to customize to our use case:
In fact the variables could be renamed without the term "json" in it, and could retrofit the legacy audit log date format to use it as well. Giving us complete control over logged date formats. |
Yes, that's right. The existing functionality uses std::ctime to produce the textual representation. Whether that function's output is "any known standard format" may be a matter of interpretation. And, yes, a loss of compatibility for existing users would be one of my concerns. One possible solution to the tz omission alone might be to, not change the existing time_stamp item at all, but add a new one (time_stamp_tz ?). In such a case, it wouldn't be natural to consider your concern to be the same. On the other hand, if a new configuration item is introduced in the way that you suggest, yes it probably could be appropriate to leave everything encapsulated in this single issue (while probably amending the title). |
Respectfully, I disagree with your position on the matter. Ctime's format isn't modifiable. Look, there's a job to be done, we either are going to work together and do it, or not. |
Description
Timezone is not included in the
time_stamp
field of audit log ifSecAuditLogFormat
is set toJSON
If
SecAuditLogFormat
is set toNative
, the time and date are written to audit log like following:Keeping all other setting the same, but setting
SecAuditLogFormat
toJSON
, the time and date are written to audit log like following:Note that it's not UTC time, it's local time on the server.
Steps to reproduce the behavior
SecAuditLogFormat
toJSON
SecAuditLogFormat
parameter. Ex.:SecAuditLogParts ABJFHZ
time_stamp
field in the latest recordExpected behavior
time_stamp
field whenSecAuditLogFormat
is set toJSON
time_stamp
always contains UTC time and not local timetime_stamp
format in configuration file (which I couldn't find)Rationale
Imagine modsecurity audit logs are shipped to ELK or other log management system from multiple servers, including those located in regions with with daylight saving time. Then there's no common way to correctly parse the
time_stamp
field given that different servers might be in different timezone and also timezone is not persistent for some of them.Server
The text was updated successfully, but these errors were encountered: