]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: hlua: fix stack overflow in httpclient headers conversion
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 7 Apr 2026 07:48:07 +0000 (09:48 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Tue, 7 Apr 2026 11:31:39 +0000 (13:31 +0200)
commit2db801c63501750b7ebd02c9390cc2138ae6df25
tree93254616e60b89aabf788512aeee8746f98d7a0d
parenta03120e228abc654d1f0d5bcb0240c6972721735
BUG/MINOR: hlua: fix stack overflow in httpclient headers conversion

hlua_httpclient_table_to_hdrs() declares a VLA of size
global.tune.max_http_hdr (default 101) on the stack but never checks
hdr_num against that bound. A Lua script that supplies a header table
with more than 101 values writes struct http_hdr entries (two ist =
two heap pointers + two lengths) past the end of the VLA, smashing
the stack frame.

Trigger from any Lua action/task/service:

    local hc = core.httpclient()
    local v = {}
    for i = 1, 300 do v[i] = "x" end
    hc:get{ url = "http://127.0.0.1/", headers = { ["X"] = v } }

Each out-of-bounds entry writes a heap pointer (controllable
allocation contents via istdup) plus an attacker-chosen length onto
the stack, overwriting the saved return address.

[wla: this is only reachable if the Lua script passes more than
max_http_hdr header values, which requires access to the script itself]

This must be backported as far as the httpclient Lua API exists.

Signed-off-by: William Lallemand <wlallemand@haproxy.com>
src/hlua.c