Merged
Conversation
There is an issue parsing PCRE patterns if the pattern contains a '/' in the middle, followed by a ':'. When splitting the subsignature (or yara regex string) by ':' delimiters to identify the offset, it will inadvertently think that the '/' in the middle of the sig is the end of the PCRE string and will therefore consider the ':' in the string as valid delimiter instead of ignoring it for being inside of the regex string. The solution I came up with is to ignore all content after a '/' when tokenizing rather than ignoring content between a matching pair of /'s. This works for LDB signatures because PCRE subsignatures are always the last subsignature and because a ':' never comes *after* the PCRE string. It works for YARA rules because the `cli_tokenize()` function is only ever used on the regex strings, never on the whole rule. Fixes: Cisco-Talos#594
ragusaa
approved these changes
Aug 8, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix issue loading regex sigs containing '/' and ':'
There is an issue parsing PCRE patterns if the pattern contains a '/' in
the middle, followed by a ':'. When splitting the subsignature (or yara
regex string) by ':' delimiters to identify the offset, it will
inadvertently think that the '/' in the middle of the sig is the end of
the PCRE string and will therefore consider the ':' in the string as
valid delimiter instead of ignoring it for being inside of the regex
string.
The solution I came up with is to ignore all content after a '/' when
tokenizing rather than ignoring content between a matching pair of /'s.
This works for LDB signatures because PCRE subsignatures are always
the last subsignature and because a ':' never comes after the PCRE
string.
It works for YARA rules because the
cli_tokenize()function is onlyever used on the regex strings, never on the whole rule.
Fixes: Version 0.105 load yara regex failed #594
Test: Add test for LDB & Yara regex rules with : + /
Also update generated sys.rs file (unrelated, just neglected in previous change)