]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: http-ana: don't crash on "keep-query" in a response redirect
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 6 Aug 2026 07:28:26 +0000 (09:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Aug 2026 08:29:19 +0000 (10:29 +0200)
commit1af221457bae61ea898e5c672a4fd65c1aefcca5
treeb4cf9ba0dcea6fc35421a47051c53ac74ba91c61
parent7592771f0c6ffa47a6eaba328216c425ffe5c3be
BUG/MEDIUM: http-ana: don't crash on "keep-query" in a response redirect

http_apply_redirect_rule() always takes its HTX from the request channel
(htxbuf(&s->req.buf)), and the "keep-query" option rebuilds the query string
from the request start line. This works for a request redirect, but the
option is also accepted on "http-response redirect", and by then the request
has usually been forwarded and its buffer is empty, so http_get_stline()
returns NULL and htx_sl_req_uri() dereferences it. Thus a rule such as
"http-response redirect location /moved keep-query" crashes on the first
request that matches it (reproduced with a plain "GET /foo?a=b").

There is no query-string to preserve once the request is gone, so let's skip
that part when the start line is no longer available and emit the location
as-is. Scheme- and prefix-based redirects are rejected on the response path
by the parser, so they are left untouched.

This was introduced in 3.1 by commit b2877db47 ("MINOR: http-ana: Add
option to keep query-string on a localtion-based redirect"). It must be
backported to 3.1.

Reported-by: Claude (ANT-2026-7AZMS41X)
src/http_ana.c