Before you post: Your responses to these questions will help the community help you. Please complete this template if you’re asking a support question. Don’t forget to select tags to help index your topic!
1. Describe your incident:
I log nginx via json to graylog and it is working fine. But now I detected that on some messages i have a small problem.
The messages results from an attack vector, where the request is displayed as
eg, unicode encoded zero. The problem: when I set it to a message field “request” the message field is empty because of 0 string.
I didn’t found any way to print the escaped string as above into a field. The example above is taken from the original message I parsed with json.
When I try to use urldecode same, because it requires a string as input which is empty after to_string(), too… Using a default value does not help - default is only used when input is null - but input isn’t null…
In the example I posted here the content of the json-field “request” is a bit different but this is how this messages looks like. And as said: the problem is that I can’t avoid that the “request” field is interpreted.
Even that graylogs displays it escaped … All fields from message above are set into the message in pipeline, only the “request” field keeps NULL.
No, this is of course not all. this is just the result when an attacker tries to send weird data - nginx just records this data as request of course regular data are parsed perfect and I get nice looking log entries.
example: when you do a “telnet your-webserver 443” and then just type a few signs and hit enter you will see this in logs. the attacker just send multiple utf-8-non-printable characters to check if there is a vulnerable software listening on this port.
ok, i think, there should be an option for “to_string” that non-printable characters are converted into into something like what graylog show me in the original message …
No. to_string does not help because it converts all these “\u0000” to a string containing the ascii value 0, eg, an empty string.
Parsing the JSON isn’t a problem. I can’t parse this as described in this article because it parses the result of to_string - an empty string. After all, I can’t avoid the conversion to (char)0. Value 0, not letter 0.
Eg, I’m missing a parameter “escape_nonprintable=(yes|no)” for to_string and wonder that graylog displays the original message like shown above but I can’t do it.