]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: sample: parse json_query integers within the token length
authorGihyeon Ryu <rlgusryu@gmail.com>
Wed, 11 Nov 2026 10:00:12 +0000 (10:00 +0000)
committerOlivier Houchard <cognet@ci0.org>
Mon, 16 Nov 2026 14:55:56 +0000 (15:55 +0100)
commitc1ba5a4b6692b501264ce3f6a9698e20e10bb499
treebe5c6cc92945243a17a67399201a7b2f8e60d437
parent3199d13830badb0eca8d935fc038d2434c985eb5
BUG/MEDIUM: sample: parse json_query integers within the token length

For the "int" output type, sample_conv_json_query() converts the token
with strtoll(token, NULL, 0). The token points into the sample, which is
not NUL-terminated, and its length is ignored. When the input ends
inside a number (for example a truncated body '{"amount":1'), the
parsing goes on past the end of the sample, into the remaining bytes of
the buffer, which may hold digits left by a previous request, possibly
from another client. Those digits then become part of the returned
value, which may bypass a range check, or be reflected to the client.
Numbers using an exponent or a fraction are also misparsed ("1e5" gives
1).

The number is now parsed with mjson_get_number(), which stays within the
token, then range checked as a double before being converted. Truncation
of fractions is kept.

This should be backported to all stable branches.
src/sample.c