You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In src/os_regex/os_pcre2_compile.c the OSPcre2_Compile function dereferences the const char *pattern variable at [0] and [pattern_len - 1] without checking pattern_len is >= 1.
This results in an out-of-bounds heap read at pattern[-1] when pattern_len is 0, e.g. with an empty regex (pattern = "").
This code was introduced in b6f1e14 when PCRE2 support was added on Jan 22nd, 2019. I believe it affects OSSEC v3.3.0+
I don't believe this is exploitable because no attacker controlled PCRE2 regular expressions are compiled by OSSEC.
As one example this bug is trigged when using an ossec-analysisd binary built with Address Sanitizer due to the empty regex in the <program_name_pcre2> element of the second "pam" decoder in rules/decoder.xml:
Likely the best fix is to have OSPcre2_Compile return an error when pattern_len == 0 before trying to optimize the empty pattern. If this is done the empty <program_name_pcre2> element in the PAM decoder will also need to be removed.
The text was updated successfully, but these errors were encountered:
In
src/os_regex/os_pcre2_compile.c
theOSPcre2_Compile
function dereferences theconst char *pattern
variable at[0]
and[pattern_len - 1]
without checkingpattern_len
is >= 1.ossec-hids/src/os_regex/os_pcre2_compile.c
Lines 64 to 65 in abb36d4
This results in an out-of-bounds heap read at
pattern[-1]
whenpattern_len
is 0, e.g. with an empty regex (pattern = ""
).This code was introduced in b6f1e14 when PCRE2 support was added on Jan 22nd, 2019. I believe it affects OSSEC v3.3.0+
I don't believe this is exploitable because no attacker controlled PCRE2 regular expressions are compiled by OSSEC.
As one example this bug is trigged when using an
ossec-analysisd
binary built with Address Sanitizer due to the empty regex in the<program_name_pcre2>
element of the second "pam" decoder inrules/decoder.xml
:ossec-hids/etc/decoder.xml
Lines 53 to 56 in abb36d4
Likely the best fix is to have
OSPcre2_Compile
return an error whenpattern_len == 0
before trying to optimize the empty pattern. If this is done the empty<program_name_pcre2>
element in the PAM decoder will also need to be removed.The text was updated successfully, but these errors were encountered: