]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: mux-fcgi: avoid out-of-bounds path decoding
authorKelly Kane <kelly@hawknetworks.com>
Tue, 17 Nov 2026 22:15:43 +0000 (22:15 +0000)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 23 Nov 2026 12:34:50 +0000 (13:34 +0100)
A client request can make the FastCGI path copy exactly fill its
scratch buffer. b_tail() then wraps to the start, so subtracting the
path length points before the buffer. URL decoding reads and writes
there instead of reading the copied path.

Require one free byte for ist0()'s terminator. The request then
follows the existing error path; ordinary paths keep working.

Commit a01ba66bc2 rejected oversized copies but missed exact fits.

This should be backported to affected stable branches.

Signed-off-by: Kelly Kane <kelly@hawknetworks.com>
src/mux_fcgi.c

index ff7554ea07dd36274785473d19a66201becfbfae..01f726bfbaa2628a6851ba598272debbe81bdeb3 100644 (file)
@@ -1382,9 +1382,9 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
                }
 
                /* Decode the path. it must first be copied to keep the URI
-                * untouched.
+                * untouched. Keep room for the terminating zero added by ist0().
                 */
-               if (!chunk_istcat(params->p, path))
+               if (path.len >= b_room(params->p) || !chunk_istcat(params->p, path))
                        goto error;
                path.ptr = b_tail(params->p) - path.len;
                len = url_decode(ist0(path), 0);