Modsecurity 블록이 내 합법적인 XHR POST 요청을 차단합니다(403 금지).

Modsecurity 블록이 내 합법적인 XHR POST 요청을 차단합니다(403 금지).

나는 modsecurity 주제를 처음 접했기 때문에 대답이 사소할 수도 있지만 ...

기본 권장 규칙 세트인 coreruleset-3.3.0을 사용하여 새 nginx/1.24.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

로그 보고서는 다음과 같습니다.

  1. "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"] 
  1. "불법 콘텐츠 유형 헤더" - "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"] 
  1. "잘못된 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"] 

그래서 저는 완전히 놀랐고 규칙이 합법적인 것처럼 보이지만 규칙 중 어느 하나도 어길 생각이 없기 때문에 어떻게 해야 할지 모르겠습니다.

관련 정보