0

After updating to CRS 3.3.4, I want to update the regular expression of the rules 920600, 921421, 921422 and 922110. but the command util/regexp-assemble/regexp-assemble.py update 920600 does not work. In other words, regexp-assemble.py does not exist. How should I run the commands to update the intended regular expressions?

Update: For example for the rule 920600 the rx is as follows:

^(?:(?:*|[^"(),/:;<=>?![\x5c]{}]+)/(?:*|[^"(),/:;<=>?![\x5c]{}]+))(?:\s*+;\s*+(?:(?:charset\s*+=\s*+(?:"?(?:iso-8859-15?|windows-1252|utf-8)\b"?))|(?:(?:c(?:h(?:a(?:r(?:s(?:e[^t"(),/:;<=>?![\x5c]{}]|[^e"(),/:;<=>?![\x5c]{}])|[^s"(),/:;<=>?![\x5c]{}])|[^r"(),/:;<=>?![\x5c]{}])|[^a"(),/:;<=>?![\x5c]{}])|[^h"(),/:;<=>?![\x5c]{}])|[^c"(),/:;<=>?![\x5c]{}])[^"(),/:;<=>?![\x5c]{}](?:)\s+=\s*+[^(),/:;<=>?![\x5c]{}]+)|;?))(?:\s+,\s*+(?:(?:*|[^"(),/:;<=>?![\x5c]{}]+)/(?:*|[^"(),/:;<=>?![\x5c]{}]+))(?:\s*+;\s*+(?:(?:charset\s*+=\s*+(?:"?(?:iso-8859-15?|windows-1252|utf-8)\b"?))|(?:(?:c(?:h(?:a(?:r(?:s(?:e[^t"(),/:;<=>?![\x5c]{}]|[^e"(),/:;<=>?![\x5c]{}])|[^s"(),/:;<=>?![\x5c]{}])|[^r"(),/:;<=>?![\x5c]{}])|[^a"(),/:;<=>?![\x5c]{}])|[^h"(),/:;<=>?![\x5c]{}])|[^c"(),/:;<=>?![\x5c]{}])[^"(),/:;<=>?![\x5c]{}](?:)\s+=\s*+[^(),/:;<=>?![\x5c]{}]+)|;?)))$

And after running the command ./regexp-assemble.pl 920600.data (which https://security.stackexchange.com/users/260216/franbuehler has suggested) the output is as follows:

(?:##!(?: (?:https://(?:httpwg.org/specs/rfc723(?:1.html#request.conneg|0.html)|coreruleset.org/docs/development/regexp_assemble/.)|(?:Accept header by following the specification as far a|list of allowed charset|Helper)s|to (?:reduce complexity and the risk of false positiv|a list of explicitly allowed valu)es.|The expression generated from this file matches a full HTTP|Where possible, the expression matches tokens "loosely", |necessary, while restricting the charset parameter|Please refer to the documentation at|Specifications:|Main assembly)|> template (?:(?:non-token-(?:chars "{{non-token-with-dquote-chars}|with-dquote-chars (),/:;<=>?![\x5c]{)|media-type {{type-subtype}}/{{type-subtype})}|t(?:oken-(?:with-dquote-chars [^{{non-token-with-dquote-chars}}]|chars [^{{non-token-chars}}])|ype-subtype (?:*|{{token-chars}}+)))|$ $|^ ^)| (?:##!(?: (?:(?:Note that this doesn't follow the RFC strictly|anything is allowed here that is not "charset"|specified, comma separated|terminating semi-colons).|Clients like to violate the RFC, be lenient with|If the first part wasn't a "charset", then|Multiple "media-range" expressions can be)|=(?:>(?: allowed-charsets)?|< allowed-charsets)|> assemble|<)| ##!> include allowed-charsets)|(?:c(?:h(?:a(?:r(?:s(?:e[^t{{non-token-chars}}]|[^e{{non-token-chars}}])|[^s{{non-token-chars}}])|[^r{{non-token-chars}}])|[^a{{non-token-chars}}])|[^h{{non-token-chars}}])|[^c{{non-token-chars}}]){{token-chars}}|(?:)\s+=\s*+{{token-with-dquote-chars}}+|\b"?)))|(?:{{media-type}})|(?:))?)|;?||)?

0

1 Answer 1

2

CRS Dev-On-Duty here. What would you like to achieve or why would you like to update the rules? We do not recommend to directly change the rules, but instead to tune them. Have a look at this tuning guide: https://www.netnea.com/cms/apache-tutorial-8_handling-false-positives-modsecurity-core-rule-set/

If you really need to update the rules, you have to do this manually (not with update) with cd util/regexp-assemble and then ./regexp-assemble.pl regexp-9xxxxx.data. I see that the comment in the rule file is wrong.

9
  • As an experience, if I do not update the regular expressions, the rules do not work correctly. The command ./regexp-assemble.pl regexp-9xxxxx.data does not work. Indeed regexp-9xxxxx.data des not exist
    – user288156
    Commented Jan 19, 2023 at 5:52
  • 1
    The tuning, if you do it in a correct way and in the right place, should work. And if you have problems with the rules you can open an issue on our GitHub project and describe exactly what's not working: github.com/coreruleset/coreruleset. The data or txt files should be in the same directory, maybe the names are a bit different. This will change in the CRS 4.0 release. Commented Jan 19, 2023 at 7:32
  • The command that you mentioned in your answer does not have a correct output. (./regexp-assemble.pl 9xxxxx.data). I need to update these rules.
    – user288156
    Commented Jan 21, 2023 at 13:27
  • If you do an ls in the directory util/regexp-assemble, what do you see? Do you find the perl script and the data or txt files you need for your rules? If yes, please provide your output here, that is not correct. Commented Jan 22, 2023 at 8:35
  • Yes the intended files exist. I edited my question to show the output
    – user288156
    Commented Jan 23, 2023 at 11:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .