Repository navigation
fix(traefik-logs): parse CLF fields with escaped quotes - #1978
Conversation
|
@sabban sorry to ping you but the AI review did not start |
|
Hi, Thank you for your contribution. From reading your PR I suspect that your change add the exact same issue would happen with "" at the end of the User-Agent. Can you test with a generated log line with Regards, |
Traefik escapes " only since 3.6.18 and 3.7.2, and never escapes \. Read referer and user agent with lazy DATA, anchor the end of the line and read the router with NOTDQUOTE so a crafted user agent cannot shift the trailing fields. Unescape \" to match the JSON format.
|
You're right, thanks. I tested it on a real Traefik with the User-Agent and Referer headers kept. Traefik escapes I switched the referer and the user agent to I also unescape I added test lines for both escaped and raw output. All hubtests pass locally, and I checked the escaped cases with |
Description
Fixes #1977. Traefik writes a
"inside the Referer or the User-Agent as\", but only since 3.6.18 and 3.7.2. Older versions, 2.11 included, write it raw.\is never escaped.NOTDQUOTErefused the escaped quote and the whole CLF line was dropped.I read the referer and the user agent with
DATA. I anchored the end of the line with$, and I read the router withNOTDQUOTE. With that, a crafted user agent cannot shift the request counter, the router or the server URL, whether Traefik escapes the quote or not. I also unescape\"in both fields so CLF gives the same value as the JSON format.I added lines to the
traefik_clftest. They cover an escaped quote, a trailing backslash, a quote in the referer, user agents built to shift the fields, and raw quotes as older Traefik writes them.Checklist