]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: hlua: fix format-string vulnerability in Patref error path
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 7 Apr 2026 07:48:13 +0000 (09:48 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Tue, 7 Apr 2026 12:18:13 +0000 (14:18 +0200)
commitd6284470e4420d4c0ce2e65e071e26903b9a9a20
treeaf5ab60f41ac6d46a27d5fa9b6ac27f6190ed42d
parent2db801c63501750b7ebd02c9390cc2138ae6df25
BUG/MINOR: hlua: fix format-string vulnerability in Patref error path

hlua_error() is a printf-family function (calls vsnprintf), but
hlua_patref_set, hlua_patref_add, and _hlua_patref_add_bulk pass
errmsg directly as the format string. errmsg is built by pattern.c
helpers that embed the user-supplied key or value verbatim, e.g.
pat_ref_set_elt() generates "unable to parse '<value>'".

A Lua script calling:

    ref:set("key", "%p.%p.%p.%p.%p.%p.%p.%p")

against a map with an integer output type (where the parse fails)
gets stack/register contents formatted into the (nil, err) return
value -> ASLR/canary leak. With %n and no _FORTIFY_SOURCE this
becomes an arbitrary write primitive.

This must be backported as far as the Patref Lua API exists.
src/hlua_fcn.c