-
Notifications
You must be signed in to change notification settings - Fork 283
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
Fixed auditlog in case of internal redirect #90
Conversation
I changed the value of the parameter I also added a test cases for a custom error page displaying with ModSecurity enabled. |
I think that this PR should be improved. Although it gives expected behaviour when displaying a custom error page, but since the handler is running earlier, some information can't be falls into the audit log (e.g. response headers). Also, the response code in the audit log is not always correspond to reality. |
Hello, it's any change to have a working solution for this issue? |
When this PR will be merged? |
Hi @awmackowiak, I am sorry to say that this patch is still queued for review. There is no ETA yet. However, you can apply it under your own branch and make use of it. If you do, please let us know if there was any issue. |
Hello guys. I think this is a really needed feature. You almost always want to show a custom error page for blocked request and at the same time you also want to know why the request was blocked. What is the reason of not merging this PR? Thanks. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days |
Hello guys. Can you re-open and consider this PR? We've been using https://github.com/AirisX/ModSecurity-nginx/tree/fix/auditlog for several months and haven't noticed any issue. |
The "nostale" tag has been set for this one and it's now reopened. We'll get to it when possible. Thank you. |
Hello @zimmerle and @defanator, do you think it's possible to merge https://github.com/AirisX/ModSecurity-nginx/tree/fix/auditlog? Thanks. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days |
Hello @zimmerle and @defanator, can you review the MR? |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days |
Given the 'nostale' tag, this item should not have been closed by the bot. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days |
@AirisX just made yet another attempt to check this one, and here's what I'm getting with additional tests incorporated into
Tests are fine:
Error log and access log entries are also fine:
However, audit log contains the wrong response code:
I saw your mention here - #90 (comment) - have you had any chance to look at this? UPDATE: I took your original tests and did a few modifications incl. additional tests for response codes in audit log: |
@AirisX I made an initial attempt to improve at least a part about getting actual response code to audit logs here - https://github.com/defanator/ModSecurity-nginx/tree/PR90 (the defanator@cd3f904 commit). Appreciate if you would take a look. @zimmerle is it safe to call |
msc_update_status_code will keep ModSecurity updated for the HTTP response code, it is basically used to feed the variable RESPONSE_STATUS and provide information for the AuditLogs. This value for status code is also meant to be set whenever processResponseHeaders is called. Not to confuse this value with the value set by the status action. ModSecurity may ask the webserver to return a given return code. Still, the webserver decides to perform something else. This value set on msc_update_status_code is meant to hold whatever the webserver returns to the user. Having said that, if you set the status value before having the response headers ready, it may cause a mismatch between what you have expected to deliver and what was delivered. Regardless it is likely that the value is going to be updated by processResponseHeaders. Keep in mind that the audit log will consider the last value set before its execution. Calling msc_update_status_code after processResponseHeaders but before the log phase will change the audit logs' value. Likewise, the RESPONSE_STATUS variable will have its value updated for each time msc_update_status_code is called. The only problem that I can think of is if one may rely on the not defined behavior of using RESPONSE_STATUS in a rule whereas the phase is prior to what we understand to be a determined value for RESPONSE_STATUS -- Status code that is returned to the user. As long as we inform ModSecurity the response status code correctly for the AuditLogs, I think it is safe to set the variable. msc_update_status_codeprocessResponseHeaders |
Thanks @AirisX and @defanator. Closing this in favor of: #241 |
The key problem is that in case of internal redirection, for example, to a custom error page, the logger registered on
NGX_HTTP_LOG_PHASE
will never work.