Feature Request: Wildcard/pattern support in ctl:ruleRemoveTargetById (v3)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず src/actions/ctl/rule_remove_target_by_id.cc と src/rule_with_operator.cc を読み、init()、getFinalVars、評価ループに注目してください。Utils::Regex がどのように使われているか、またトランザクション状態が除外をどのように保持しているかを確認してください。リテラルのターゲットが引き続き機能し、有効なパターンが実行時に変数名とマッチし、無効な正規表現が設定中に失敗し、提示された ReDoS の制限に対処できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Hi team! This is my first ask/contribution to ModSecurity. I'm hoping to help improve false positive management for folks using CRS — please let me know if I can clarify anything or adjust this proposal.
Is your feature request related to a problem? Please describe.
Currently, ctl:ruleRemoveTargetById only allows excluding a Core Rule Set (CRS) rule from inspecting a literal, exact variable name (e.g., ARGS:json.JobDescription). It does not support wildcards or regular expressions.
This creates a significant pain point for modern APIs accepting JSON arrays or GraphQL payloads, where keys are dynamic:
- Payload:
[{"JobDescription": "..."}, {"JobDescription": "..."}, ...] - Variables:
ARGS:json.0.JobDescription,ARGS:json.1.JobDescription, …
Excluding these requires listing every possible index, which is impractical and leads to users disabling rules entirely or losing protection for the whole endpoint via path exclusions.
Note: This request is related to the legacy v2 PR #3121 and Issue #911, but focuses specifically on a v3 implementation.
Describe the solution you'd like
Extend ctl:ruleRemoveTargetById to accept a pattern (regex) that matches variable names, mirroring the existing regex support in SecRuleUpdateTargetById, but enabling runtime/URI-scoped use.
Example Syntax:
SecRule REQUEST_URI "@beginsWith /api/jobs" \
"id:100100,phase:1,pass,nolog,ctl:ruleRemoveTargetById=932125;ARGS:/^json\.\d+\.JobDescription$/"
Expected Behavior: When the target rule inspects variables, any variable whose name matches the compiled pattern is excluded. Literal targets must continue to work unchanged. Invalid regex should fail at config load.
Describe alternatives you've considered
- Path/method exclusion: Loses protection for the entire endpoint.
- SecRuleUpdateTargetById: Applies globally at configure-time, which is risky if other endpoints share the same JSON structure.
Technical Feasibility & Security Considerations (v3)
The change is feasible in v3 with localized edits, as the engine already utilizes Utils::Regex (PCRE2) for variable matching.
src/actions/ctl/rule_remove_target_by_id.cc: Ininit(), detect theCOLLECTION:/.../pattern. If it's a regex, compile viaUtils::Regexand push to the transaction state.src/rule_with_operator.cc: IngetFinalVarsand the evaluate loop, check exclusions against regex targets usingm_regex->searchAll(varName).size() > 0.
ReDoS Mitigations Risks:
Because the variable name (e.g., JSON key) is user-controlled, strict limits are required to prevent ReDoS via the ctl evaluation:
- Subject Length Limit: Cap the evaluated string (variable name) at 256 characters. If exceeded, skip the regex match (fail closed/evaluate the rule).
- Match Limits: Utilize
pcre2_set_match_limit()for this specific code path. - Compile-time validation: Reject known ReDoS patterns at config load.
- 主要言語
- C++
- スター
- 9.8k
- フォーク
- 1.8k
- 平均マージ
- 2時間 46分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
owasp-modsecurity/ModSecurity のほかの issue
-
2.x Platform - IIS
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
owasp-modsecurity/ModSecurity#3623 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
2.x Platform - IIS
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
owasp-modsecurity/ModSecurity#3621 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
2.x Platform - IIS
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
owasp-modsecurity/ModSecurity#3619 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
2.x Platform - IIS
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
owasp-modsecurity/ModSecurity#3612 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
3.x
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
owasp-modsecurity/ModSecurity#3580 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
owasp-modsecurity/ModSecurity の issue をすべて見る
似ている issue
-
`enzymexla.linalg.lu` lowering fails for a tall matrix: the permutation is built with the pivot typeオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
EnzymeAD/Enzyme-JAX#3286 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
apache/iceberg-cpp#973 ·
メンテナーはふだん 1 日以内に返信
-
feature request
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信