Repository navigation
Conversation
With the default "accessLog: {}" Traefik drops all request headers, so
the User-Agent field of every access log line is "-". Keep only the
User-Agent header: CrowdSec scenarios such as http-bad-user-agent and
external SIEMs can use it, while Referer, Cookie and Authorization stay
dropped.
New modules get the setting from create-module. Existing modules get it
from update-module.d/15upgrade_v3, only when accessLog is still the
default "{}": a disabled or customized access log is left untouched.
NethServer/dev#8233
Co-Authored-By: Claude Opus 5.5 <[email protected]>
stephdl
left a comment
There was a problem hiding this comment.
Thanks for this. I tested it on a node with CrowdSec and Wazuh, and it works.
I'm not sure the gain is worth it. Scanners caught by http-bad-user-agent usually probe paths too, and the path based scenarios already ban them a few requests later. Wazuh gets the field, but no rule uses it yet. On the other side, it's more user data stored in four places and more log volume.
There is also a side effect. Traefik writes a quote in the User-Agent as \", and the hub parser crowdsecurity/traefik-logs drops those lines. A client with a " in its User-Agent would skip every HTTP scenario. NethServer/ns8-crowdsec#226 fixes it, but we would have to maintain a copy of a hub parser on our side until the hub fixes it upstream.
If it goes in, I'd prefer it opt-in, kept across restore, with a README note on privacy. A bare accessLog: (None) also needs handling in 15upgrade_v3.
@DavidePrincipi your call. I keep NethServer/ns8-crowdsec#226 in draft until then.
|
Thanks @stephdl for testing it, and for catching the escaped-quote problem in the hub parser. I agree that NethServer/ns8-crowdsec#226 must be released before or together with this PR. About Wazuh: the stock ruleset already reads the User-Agent in the access log. Rules 31166/31168 (Shellshock) look for I'm fine with opt-in. If @DavidePrincipi agrees, I'll rework the PR: an action to turn the User-Agent on and off, kept across restore, a README note on privacy, and handling of a bare |
| # (access log disabled) or a custom one is left untouched. | ||
| if static_cfg.get('accessLog') != {}: | ||
| return # nothing to do | ||
| print("Keep the User-Agent request header in the Traefik access log") |
There was a problem hiding this comment.
I like the PR, just a little cleanup: remove this line since it only pollutes the logs
| print("Keep the User-Agent request header in the Traefik access log") |
A bare "accessLog:" loads as None and enables the default access log
like "accessLog: {}", so change it too. Also drop the print: it only
adds noise to the logs.
NethServer/dev#8233
Co-Authored-By: Claude Opus 5.5 <[email protected]>
DavidePrincipi
left a comment
There was a problem hiding this comment.
Thanks @stephdl and @mactsk, a few ideas:
-
Escaped quote: before we maintain our own copy of the hub parser (NethServer/ns8-crowdsec#226), we could ask the CrowdSec team whether they'd fix
crowdsecurity/traefik-logsupstream. Either way, it might be safer to merge this only after a fix is out. -
On by default: I'd lean towards keeping the User-Agent enabled, with a README note on privacy and how to turn it off. Like the version check in #154, that means editing
traefik.yaml, since flags and env vars are ignored. The update step already leaves a changedaccessLogalone. -
Loki: an Alloy rule in core could blank the User-Agent before logs reach Loki, which keeps them much longer than the journal. CrowdSec and other local agents would still see it in the journal.
What do you think?
it worth to try but no clue when and what they will fix |
|
done sorry for the delay, let's see |
|
the pr crowdsecurity/hub#1978 has been accepted by crowdsec |
* Keep the User-Agent in the access log (default access log only) Traefik drops every request header from the access log by default, so security monitoring (CrowdSec http-bad-user-agent, SIEM) cannot recognise scanners by their User-Agent. Only the User-Agent is kept; Cookie, Authorization, Referer and all other headers stay dropped. New modules get the setting, existing modules on update, but only if accessLog is still the default; a disabled or customised access log is untouched. Same change as upstream NethServer/ns8-traefik#152. * Release notes and version 4.2.8-reworked.1 --------- Co-authored-by: Platypuschan <[email protected]>
|
@DavidePrincipi could you take another look? Point 1 is solved. The CrowdSec team merged the parser fix upstream in crowdsecurity/hub#1978. Our nodes get it with the hub upgrade timer, so I closed NethServer/ns8-crowdsec#226. Point 2 is solved too. The User-Agent stays on by default. I added an "Access log" section to the README. It covers privacy and how to turn the field off in About point 3, I'm not sure we should blank the User-Agent in Loki. Loki already stores the client IP, which says more about a person than the User-Agent. The User-Agent is useful when we analyze a past attack, after the journal has rotated. What do you think? |
With the default
accessLog: {}Traefik drops every request header, so the User-Agent field of each access log line is always"-". CrowdSec scenarios such ashttp-bad-user-agentnever match, and security monitoring tools (SIEM) cannot spot scanners or skip legitimate crawlers. NethServer/dev#8233The access log now keeps the User-Agent request header and still drops all the others (Referer, Cookie, Authorization...). The log format and file do not change: only the User-Agent field is filled in.
create-module: new modules get the setting.update-module.d/15upgrade_v3: existing modules get it on update, only ifaccessLogis still the default{}. A disabled or customized access log is left untouched.How to test
traefik.yamlhasaccessLog.fields.headerswithdefaultMode: dropandUser-Agent: keep"-"accessLog: the setting is unchangedSee also
🤖 Generated with Claude Code