]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: acl: fix a possible arg corruption in smp_fetch_acl_parse()
authorWilly Tarreau <w@1wt.eu>
Thu, 30 Apr 2026 13:40:52 +0000 (15:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 30 Apr 2026 15:39:26 +0000 (17:39 +0200)
commit3fe3a189c26e8c1daaccd0a3dff4d3f996902daa
treed52993ebeba2051d55c73939e752b4cadefa9cd7
parent2d6ebd0410c5084a78db2380f22041d4011ffd41
BUG/MINOR: acl: fix a possible arg corruption in smp_fetch_acl_parse()

smp_fetch_acl_parse() first places the newly allocated ACL sample into
the first argument to be parsed, *before* parsing it. The type is not
changed so the first argument remains of type string. In case of error,
the allocated sample is released and release_sample_expr() will call
release_sample_arg() to release the argument, possibly freeing the
string present there. And here's the catch: by overwriting the first
arguments's ->ptr entry, it happens to be located over the ->str.size
location, to not be null and to still be freed, but by pure chance
thanks to aliasing. A slight reorder of the args or buffer fields
could place it in the ->area and provoke a double-free, or even always
make the first argument's parsing fail.

Let's move the assignment after the loop has succeeded instead, and
properly set type=ARGT_PTR so that we never try to free it. The bug
appeared with the "acl()" sample fetch in 2.9 with commit 7fccccccea
("MINOR: acl: add acl() sample fetch") so it can be backported to 3.0.
src/acl.c