Escape char not handled for patterns categorised as exact match #69851
Labels
>bug
:Security/Security
Security issues without another label
Team:Security
Meta label for security team
Uh oh!
There was an error while loading. Please reload this page.
In #36017, we opitmised index matching performance by splitting the patterns into two categories: exact match and non-exact (wildcard) match.
Set.contains
was used for exact matches andAutomaton
is used for non-exact matches. The issue occurs when a pattern contains the escape char (/
), which is handled specially (basically gets dropped) when building the automaton, but passed through unchanged when building the exact match Set.For example:
ab\c
andab\c*
do not both matchab\c
. In fact, only the former exact match patternab\c
does. The patternab\c*
result in an automaton that matchesabc*
.abc\
matches exactlyabc\
whileabc\*
matches exactlyabc*
.abc\
anda*c\
, only the former matchesabc\
while the later cannot match any string that ends with a\
.In addition to the above bug, there is also a tiny missed opportunity for optimisation:
elasticsearch/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/support/StringMatcher.java
Lines 93 to 97 in c7ad737
If the chars
*
or?
is immediately after an escape char (which itself is not immediately after an escape), the pattern is in fact an exact instead of a non-exact match.The text was updated successfully, but these errors were encountered: