-
Notifications
You must be signed in to change notification settings - Fork 282
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
two server fields in json #230
Comments
Hi @nickvth I am assuming that more_clear_headers is the project available at: https://github.com/openresty/headers-more-nginx-module#more_clear_headers is that right? If so, do you happens to have any directive configured? or just have the project enabled without any configuration? |
@zimmerle ingress-nginx configured this settings by default
The project module is right. More information why this is configured. ingress-nginx project: https://github.com/kubernetes/ingress-nginx |
For the reference, here is where ModSecurity collects the headers variables - more_clear_headers removes the header here - @nickvth What happens if you use more_set_headers instead? -
|
Hi, I'm having the issue on the same environment. I've tested your suggestion with more_set_headers and it results in another duplicate Server header:
|
Thank you fro the feedback @Ricardolaponder. The list structure apparently has some left overs or we are reading it incorrectly on ModSecurity. It needs further investigation. Do you happens to have other |
These are all the modules installed, it's al default from the nginx-ingress controller image. |
Looking at this from a slightly different angle ... If there are multiple response headers with the same name, and you are using 'SecAuditLogFormat JSON' within your ModSecurity configuration, then you can indeed get audit log output with duplicate json keys. Duplicate json keys do not actually violate the json specification, however RFC-7159 does state that 'The names within an object SHOULD be unique.' [Note: 'SHOULD' not 'MUST'] In most normal situations, multiple response headers with the same name should not be present. There is at least one notable exception, however: it is not exactly rare for there to be multiple 'Set-Cookie' headers in a response. We could consider changing the json audit-log-writing to use array format for this use case, e.g.
|
@martinhsv You're right, it doesn't violate the json specification, but on why it's a problem for us is that we want to index the json events from Modsecurity into Elasticsearch. Elasticsearch by design doesn't allow duplicate field names for their documents. So as a workaround we've disabled the more_clear_headers Server; setting, but that's not preferred from a Security perspective. I still find it weird that Modsecurity returns 2 times an empty Server header, when nginx removes the Server header entirely in it's response. It doesn't feel like a "expected" response from Modsecurity. |
Running into the same issue. |
I've just hit the same issue so I will share my observations:
It seems indeed that there is an issue with modsecurity logs when the more headers directive are used. |
Just to clarify this item a little ... It seems there are really two sub-issues here: I'm just wondering how to weigh these two sub-issues. If (A) above were to be addressed via array format in the json audit log writing, would that alleviate the great majority of the concern and/or nuisance? Or is resolving, or at least explaining, (B) really the core issue? |
Puh, such an old issue - we also do have the very same issue :( |
When server-tokens off and more_clear_headers server are configured we get two server fields in json.
Elasticsearch will not parse this, because field need te be unique.
Please fix this, so we get 1 server field
example
"http_code":403,"headers":{"Server":"","Server":"","Date":"Wed, 02 Dec 2020 20:57:05 GMT","Content-Length"
The text was updated successfully, but these errors were encountered: