Skip to content

fix(parsers): keep traefik lines with escaped quotes - #226

Closed
stephdl wants to merge 1 commit into
mainfrom
feat/traefik-escaped-quote
Closed

stephdl wants to merge 1 commit into
mainfrom
feat/traefik-escaped-quote

Conversation

@stephdl

@stephdl stephdl commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

NethServer/ns8-traefik#152 makes Traefik log the User-Agent so CrowdSec can use it (NethServer/dev#8233). I tested it on a node and found a side effect. Traefik writes a quote inside the User-Agent as \", and the hub parser crowdsecurity/traefik-logs reads that field with a pattern that refuses any quote. The whole line is dropped. A client that puts a " in its User-Agent then skips every HTTP scenario, path based ones included.

Nothing changes for lines the hub parser already reads. I added a local parser nethserver/traefik-escaped-logs, a copy of the hub CLF pattern that accepts escaped quotes. Its filter only takes lines that contain \", so it runs only where the hub parser fails. The hub parser stays untouched and keeps its updates.

Today the bug can't be triggered: the User-Agent is always "-" and the Referer is dropped. A quote in the path is encoded as %22, and a raw quote in the query string still parses. So this PR should be released before or with the Traefik one.

How to test

  • Run cscli explain -v --type syslog --log '<line>' with a traefik line whose User-Agent contains \", like the one in tests/20__parsers.robot
  • Check that nethserver/traefik-escaped-logs is green, traefik_router_name is the real route, and http-sensitive-files matches on /.env
  • Check that a normal traefik line is still handled by crowdsecurity/traefik-logs

See also

crowdsecurity/traefik-logs reads the Referer and User-Agent with
NOTDQUOTE. Traefik escapes a quote in those fields as \", so the hub
parser drops the whole line and the client skips every HTTP scenario.
Add a local parser that handles only those lines.
@stephdl

stephdl commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

the pr has been accepted crowdsecurity/hub#1978, lets close it here

@stephdl stephdl closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant