Skip to content

fix 941170#2292

Merged
theMiddleBlue merged 1 commit into
coreruleset:v3.4/devfrom
theMiddleBlue:fix-941170-rx
Nov 9, 2021
Merged

fix 941170#2292
theMiddleBlue merged 1 commit into
coreruleset:v3.4/devfrom
theMiddleBlue:fix-941170-rx

Conversation

@theMiddleBlue

Copy link
Copy Markdown
Contributor

No description provided.

@theMiddleBlue
theMiddleBlue merged commit fa7f8f1 into coreruleset:v3.4/dev Nov 9, 2021
# [NoScript InjectionChecker] Attributes injection
#
SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|REQUEST_HEADERS:User-Agent|REQUEST_HEADERS:Referer|ARGS_NAMES|ARGS|XML:/* "@rx (?i)(?:\W|^)(?:javascript:(?:[\s\S]+[=\\\(\[\.<]|[\s\S]*?(?:\bname\b|[\\\\][ux]\d))|data:(?:(?:[a-z]\w+/\w[\w+-]+\w)?[;,]|[\s\S]*?;[\s\S]*?\b(?:base64|charset=)|[\s\S]*?,[\s\S]*?<[\s\S]*?\w[\s\S]*?>))|@\W*?i\W*?m\W*?p\W*?o\W*?r\W*?t\W*?(?:/\*[\s\S]*?)?(?:[\"']|\W*?u\W*?r\W*?l[\s\S]*?\()|\W*?-\W*?m\W*?o\W*?z\W*?-\W*?b\W*?i\W*?n\W*?d\W*?i\W*?n\W*?g[\s\S]*?:[\s\S]*?\W*?u\W*?r\W*?l[\s\S]*?\(" \
SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|REQUEST_HEADERS:User-Agent|REQUEST_HEADERS:Referer|ARGS_NAMES|ARGS|XML:/* "@rx (?i)(?:\W|^)(?:javascript:(?:[\s\S]+[=\\\(\[\.<]|[\s\S]*?(?:\bname\b|[\\\\][ux]\d))|data:(?:(?:[a-z]\w+/\w[\w+-]+\w)?[;,]|[\s\S]*?;[\s\S]*?\b(?:base64|charset=)|[\s\S]*?,[\s\S]*?<[\s\S]*?\w[\s\S]*?>))|@\W*?i\W*?m\W*?p\W*?o\W*?r\W*?t\W*?(?:/\*[\s\S]*?)?(?:[\"']|\W*?u\W*?r\W*?l[\s\S]*?\()|[^-]*?-\W*?m\W*?o\W*?z\W*?-\W*?b\W*?i\W*?n\W*?d\W*?i\W*?n\W*?g[^:]*?:\W*?u\W*?r\W*?l[\s\S]*?\(" \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference; [\s\S] matches any character including new lines (which . does not include).
The first replacement is equivalent, except that it does not match -.
Similar for the second one.
However, the removal of [\s\S]*? means that : can now only be followed by \W or u. This more or less excludes all characters and digits but still matches white space and new lines. If that is intentional, then the change looks good to me (the expression is more restrictive than before, which is usually ok).

fzipi added a commit that referenced this pull request Jun 2, 2026
replace [\s\S] with . in the .ra so crs-toolchain can generate a
PCRE-compatible pattern; [\s\S] expanded to [\x00-\x{10ffff}], which
fails toolchain validation and PCRE 8-bit compilation. . is
dotall-equivalent under modsec2-apache and modsec3-nginx (verified:
. matches newlines in both engines).

also revert the moz-binding branch quantifier [^-]*?- back to \W*?-,
the PCRE backtracking regression introduced in #2292 (see #4633), and
add test 6 covering the moz-binding branch, which had no coverage.
fzipi added a commit that referenced this pull request Jun 2, 2026
replace [\s\S] with . in the .ra so crs-toolchain can generate a
PCRE-compatible pattern; [\s\S] expanded to [\x00-\x{10ffff}], which
fails toolchain validation and PCRE 8-bit compilation. . is
dotall-equivalent under modsec2-apache and modsec3-nginx (verified:
. matches newlines in both engines).

also revert the moz-binding branch quantifier [^-]*?- back to \W*?-,
the PCRE backtracking regression introduced in #2292 (see #4633), and
add test 6 covering the moz-binding branch, which had no coverage.
Xhoenix pushed a commit to Xhoenix/coreruleset that referenced this pull request Jun 4, 2026
* refactor: create 941170 `.ra` file

* refactor: decompose 941170 `.ra` into sub-assemblies

* fix(941170): use . over [\s\S] and fix moz-binding perf regression

replace [\s\S] with . in the .ra so crs-toolchain can generate a
PCRE-compatible pattern; [\s\S] expanded to [\x00-\x{10ffff}], which
fails toolchain validation and PCRE 8-bit compilation. . is
dotall-equivalent under modsec2-apache and modsec3-nginx (verified:
. matches newlines in both engines).

also revert the moz-binding branch quantifier [^-]*?- back to \W*?-,
the PCRE backtracking regression introduced in coreruleset#2292 (see coreruleset#4633), and
add test 6 covering the moz-binding branch, which had no coverage.

* Apply suggestions from code review

Co-authored-by: Max Leske <[email protected]>

* chore(formatting): auto fixes from pre-commit hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Max Leske <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants