.png)
私は modsecurity のトピックについては不慣れなので、答えは簡単かもしれませんが...
新しい nginx/1.24.0 サーバーに、推奨ルールのデフォルト セットである coreruleset-3.3.0 を使用して modsecurity をセットアップしましたが、それ以降、POST XHR リクエストがブロックされています。これは、基本的な Laravel/Livewire フォームです。
modsecurity によって送信され、記録されるヘッダーは次のようになります。
POST /livewire/update HTTP/2.0
content-type: application/json
origin: https://example.com
referer: https://example.com/en
pragma: no-cache
accept-encoding: gzip, deflate, br
cookie: XSRF-TOKEN=eyJpdiI6IkJVTXpEK01rYTRYVFI1aGxjOE9T...
content-length: 540
accept-language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3
te: trailers
accept: */*
cache-control: no-cache
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0
sec-fetch-site: same-origin
sec-fetch-dest: empty
authorization: Basic Y2Z0cmFbjpjmdG9u
host: example.com
sec-fetch-mode: no-cors
ログには次のように報告されます:
- 「Content-Length HTTP ヘッダーは数値ではありません」 - しかし、私にとっては「540」は数値のように見えます。
ModSecurity: Warning. Matched "Operator `Rx' with parameter `^\d+$' against variable `REQUEST_HEADERS:content-length' (Value: `540' )
[file "/etc/nginx/modsec/coreruleset-3.3.0/rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf"]
[line "127"]
[id "920160"]
[msg "Content-Length HTTP header is not numeric"]
[data "540"]
[severity "2"]
- 「不正な Content-Type ヘッダー」 - 「application/json」がなぜ不正なのでしょうか?
ModSecurity: Warning. Matched "Operator `Rx' with parameter `^[\w/.+-]+(?... against variable `REQUEST_HEADERS:content-type' (Value: `application/json' )
[file "/etc/nginx/modsec/coreruleset-3.3.0/rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf"]
[line "915"]
[id "920470"]
[rev ""]
[msg "Illegal Content-Type header"]
[data "application/json"]
[severity "2"]
- 「無効な HTTP リクエスト ライン」 - 「POST /livewire/update HTTP/2.0」の何が無効ですか?
ModSecurity: Warning. Matched "Operator `Rx' with parameter `^(?i:(?:[a-... against variable `REQUEST_LINE' (Value: `POST /livewire/update HTTP/2.0' )
[file "/etc/nginx/modsec/coreruleset-3.3.0/rules/REQUEST-920-PROTOCOL-ENFORCEMENT.conf"]
[line "47"]
[id "920100"]
[msg "Invalid HTTP Request Line"]
[data "POST /livewire/update HTTP/2.0"]
..そしてリクエストはブロックされます
ModSecurity: Access denied with code 403 (phase 2). Matched "Operator `Ge' with parameter `5' against variable `TX:ANOMALY_SCORE' (Value: `13' )
[file "/etc/nginx/modsec/coreruleset-3.3.0/rules/REQUEST-949-BLOCKING-EVALUATION.conf"]
[line "80"]
[id "949110"]
[msg "Inbound Anomaly Score Exceeded (Total Score: 13)"]
[data ""]
[severity "2"]
それで、私は完全に驚いています。ルールは合法であるように思えるのですが、いずれのルールも破りたくないので、これについて何ができるのか分かりません。