-
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
Discussion about 'hostname' field in log #3200
Comments
So with your change, the Do I understand correctly, that using a directive like |
I think the patch would be fine. As for the alternative approach with the application, would that be the connector that calls it? |
yes, exactly. Later, and not in the library, but in the application that uses library (namely Nginx connector). But we have to be careful: if we add this method to Nginx connector, that won't work with older versions, so we have to check that function exists or not. The best was to control this we check the ModSecurity version, like it's used in other case, see this example. This is why would it be good to add this feature as soon - we can add this feature to the connector after release.
Yes, meanwhile I realized that too. Thanks. |
Exactly. With a version control - see my previous comment. |
I was still thinking about this question and made some tests. First: I wouldn't touch the field names of the log, I would keep the existing fields, namely Take a look to the Nginx's server log:
I have a vhost in my Nginx with 2 server names:
If I send a request with hostname Which one is the better? Apache uses the (I know that it is not necessary to decide now and not here - just finished a test and shared my experience.) |
I assume, that if you used |
I second @theseion, but anything is fine as long it's not an IP address. :) I mean in most cases, host header and servername should be in sync. So it does not matter too much (obviously, the source needs to be well documented for the remainder of the cases). |
No. I already tried that, but in case of default server, the |
Based on this discussion and on Slack's comments, I'm going to prepare the PR which implements a new API function that can be used to set the correct hostname. Later in application site we can decide what value do we want to set. |
Describe the bug
Libmodsecurity3 produces log (through a callback function eg. for Nginx) with unusable
[hostname]
field.[hostname]
always contains the IP address of the server, which has no informational value.Logs and dumps
An example:
As you can see, the log contains the
server
andhost
fields at the end of the line, but unfortunately the length of the line is limited (it's hard coded in Nginx to 2048 bytes), and if the request is too long (eg. there is aGET
request with some very long query string) these fields will be disappeared.To Reproduce
Send any invalid request that triggers a rule and produces a log entry.
Expected behavior
As in case of Apache's mod_security2 module, it would be fine to get the
hostname
field with the correct value.Server (please complete the following information):
Additional context
There is a previous intention to fix this issue:
#2906
but it was rejected (see the discussion). The first point was this:
The 'Host' header is untrusted user input. - which is a bit interesting, because (meanwhile I reviewed the code again) I found that the variable
SERVER_NAME
(reference) is also produced from theHost
header - see the source - without any filtering.Never mind, I would like to discuss how can we solve this issue.
My suggestions:
setRequestHostName()
(andmsc_set_request_hostname()
in C) that sets the inside variableI also created a patch for Nginx connector, here is the result:
the log:
Note, that the connector uses Nginx's
r->headers_in.server
variable, see Nginx's source.Please share your idea about this behavior and possible solutions.
The text was updated successfully, but these errors were encountered: