Behavior change in regex macro expansion from 2.9.7 to 2.9.8 affecting CRS 3.2.x and 3.3.x
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず PR #2357 と regex macro expansion path を確認し、次に提供された curl リクエストを CRS ルール 920420 に対して実行して問題を再現します。2.9.7 と 2.9.8 の debug-log の挙動を比較します。完了の条件は、ルールをトリガーせずに 2.9.7 と同様に application/soap+xml が受け入れられることです。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
The way macros are expanded to regex patterns in rules changed from ModSecurity 2.9.7 to 2.9.8.
This affects CRS 3.2.x (920420, 920480) and CRS 3.3.x (920480) that both use the feature. CRS 4.x no longer uses this features and is thus not affected.
Logs and dumps
ModSecurity 2.9.7 debug log
... Resolved macro %{tx.allowed_request_content_type} to: application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain
... Escaping pattern [^application\/x-www-form-urlencoded|multipart\/form-data|text\/xml|application\/xml|application\/soap\+xml|application\/x-amf|application\/json|application\/octet-stream|application\/csp-report|application\/xss-auditor-report|text\/plain$]
...
... Rule returned 0.
... No match, not chained -> mode NEXT_RULE.
...
ModSecurity 2.9.8 debug log
... Resolved macro %{tx.allowed_request_content_type} to: application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/soap+xml|application/x-amf|application/json|application/octet-stream|application/csp-report|application/xss-auditor-report|text/plain
... Expanded-macro pattern [^application\/x-www-form-urlencoded|multipart\/form-data|text\/xml|application\/xml|application\/soap\+xml|application\/x-amf|application\/json|application\/octet-stream|application\/csp-report|application\/xss-auditor-report|text\/plain$]
...
... Set variable "tx.anomaly_score_pl1" to "5".
...
To Reproduce
$ curl -H "Content-Type: application/soap+xml" -d "@example.xml" -v http://localhost
The content type application/soap+xml is in the list of allowed content-types for CRS 3.2.3 by default. With ModSecurity 2.9.8 it is suddenly no longer accepted and rule 920420 PL1 Request content type is not allowed by policy is being triggered by this Content-Type.
Expected behavior
Regex macro expansion behavior is the same between 2.9.7 and 2.9.8. The curl call above should not trigger CRS 920420 in version 3.2.3.
Server (please complete the following information):
- ModSecurity version (and connector): ModSecurity 2.9.8
- WebServer: Apache 2.4.63
- OS (and distro): Ubuntu
Rule Set (please complete the following information):
- CRS 3.2.x, CRS 3.3.x
Additional context
PR #2357 might be a candidate for the introduction of this bug.
- 主要言語
- 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
-
bug
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
isl-org/Open3D#7585 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Unconfirmed bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
luanti-org/luanti#17605 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
area: config area: firmware priority: P2 - medium size: S type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Mizithra/ActiveTerrain#16 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
grumpycoders/pcsx-redux#2171 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信