]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: cfgcond: limit recursion level in the condition expression parser
authorWilly Tarreau <w@1wt.eu>
Tue, 20 Jul 2021 15:58:34 +0000 (17:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 20 Jul 2021 16:03:08 +0000 (18:03 +0200)
commitdc70c18ddc9cca8913fa407a6e1448fb1f576872
treeebf9266fc15143b08ae2f180536f15ae5bf11c8b
parent048368ef6fb5528982238c19dd5b164457336657
BUG/MEDIUM: cfgcond: limit recursion level in the condition expression parser

Oss-fuzz reports in issue 36328 that we can recurse too far by passing
extremely deep expressions to the ".if" parser. I thought we were still
limited to the 1024 chars per line, that would be highly sufficient, but
we don't have any limit now :-/

Let's just pass a maximum recursion counter to the recursive parsers.
It's decremented for each call and the expression fails if it reaches
zero. On the most complex paths it can add 3 levels per parenthesis,
so with a limit of 1024, that's roughly 343 nested sub-expressions that
are supported in the worst case. That's more than sufficient, for just
a few kB of RAM.

No backport is needed.
include/haproxy/cfgcond.h
include/haproxy/defaults.h
src/cfgcond.c