]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: sample: reject a \0 byte in url_dec, json_query and jwt_*_query
authorFrederic Lecaille <flecaille@haproxy.com>
Fri, 11 Sep 2026 13:49:19 +0000 (15:49 +0200)
committerFrederic Lecaille <flecaille@haproxy.com>
Fri, 11 Sep 2026 13:52:40 +0000 (15:52 +0200)
commit37204a71ac6eea761fe01aed96b3cd340a0ceda4
treec5c096141626d5147666fa9eb58de8d496d895c6
parent209c027c1a02791f80400f37c54bcc1718be30b6
BUG/MINOR: sample: reject a \0 byte in url_dec, json_query and jwt_*_query

A string sample cannot contain a \0 byte by design: this is what
distinguishes it from a binary sample, and every consumer relies on it.
Yet url_dec decoded "%00" to a \0, json_query decoded "\u0000" to one,
and jwt_header_query/jwt_payload_query could return one from the base64
decoded JSON. Such a sample was then matched by "-m str" on its prefix
only, so "/public%00/admin" matched "/public" and an allow-list could be
bypassed.

Commit 442f583f4 ("BUG/MINOR: pattern: do not match a string with an
embedded \0 on its prefix") worked around it in pat_match_str(), which
is the wrong place since such a string must not exist at all.

This commit reverts it and fixes the producers instead: url_decode() now
fails on "%00" like it does on an invalid sequence, and json_query and
jwt_*_query fail on a decoded \0. This is also cheaper, as the string
is checked once where it is produced instead of on every call to
pat_match_str().

This must be backported to all stable branches, in place of 442f583f4
where it was not yet backported.
src/pattern.c
src/sample.c
src/tools.c