on
ModSecurity: Access denied with code 44 (phase 2). Match of "eq 0...
ModSecurity: Access denied with code 44 (phase 2). Match of "eq 0...
728x90
반응형
워드프레스로 만든 웹사이트의 게시판에 사진을 업로드 하는 중에 발생했다.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.More information about this error may be available in the server error log.
정말이지 달갑지 않은 메시지이다. 게시판에 올려야 할 사진이 대충 400장 이상인데..잘 올라가다가 갑자기 오류가 발생했을까... 아파치 로그에서 아래와 같은 메시지를 확인할 수 있었다.
ModSecurity: Access denied with code 44 (phase 2). Match of "eq 0" against "MULTIPART_UNMATCHED_BOUNDARY" required. [file "/etc/httpd/conf.d/mod_security.conf"] [line "34"] [id "200003"] [msg "Multipart parser detected a possible unmatched boundary."] [hostname ~~~~ [http:error] [pid 9893] [client ip-address] AH01579: Invalid response status 44, referer: https://~~~~
메시지에서 mod_security.conf의 34번째 줄.....
1 2 # ModSecurity Core Rules Set configuration 3 IncludeOptional modsecurity.d/*.conf 4 IncludeOptional modsecurity.d/activated_rules/*.conf 5 6 # Default recommended configuration 7 SecRuleEngine On 8 SecRequestBodyAccess On 9 SecRule REQUEST_HEADERS:Content-Type "text/xml" \ 10 "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML" 11 SecRequestBodyLimit 13107200 12 SecRequestBodyNoFilesLimit 131072 13 SecRequestBodyInMemoryLimit 131072 14 SecRequestBodyLimitAction Reject 15 SecRule REQBODY_ERROR "!@eq 0" \ 16 "id:'200001', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2" 17 SecRule MULTIPART_STRICT_ERROR "!@eq 0" \ 18 "id:'200002',phase:2,t:none,log,deny,status:44,msg:'Multipart request body \ 19 failed strict validation: \ 20 PE %{REQBODY_PROCESSOR_ERROR}, \ 21 BQ %{MULTIPART_BOUNDARY_QUOTED}, \ 22 BW %{MULTIPART_BOUNDARY_WHITESPACE}, \ 23 DB %{MULTIPART_DATA_BEFORE}, \ 24 DA %{MULTIPART_DATA_AFTER}, \ 25 HF %{MULTIPART_HEADER_FOLDING}, \ 26 LF %{MULTIPART_LF_LINE}, \ 27 SM %{MULTIPART_MISSING_SEMICOLON}, \ 28 IQ %{MULTIPART_INVALID_QUOTING}, \ 29 IP %{MULTIPART_INVALID_PART}, \ 30 IH %{MULTIPART_INVALID_HEADER_FOLDING}, \ 31 FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'" 32 33 SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" \ 34 "id:'200003',phase:2,t:none,log,deny,status:44,msg:'Multipart parser detected a possible unmatched boundary.'" 35 36 SecPcreMatchLimit 1000 37 SecPcreMatchLimitRecursion 1000 38 39 SecRule TX:/^MSC_/ "!@streq 0" \ 40 "id:'200004',phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'" 41 42 SecResponseBodyAccess Off 43 SecDebugLog /var/log/httpd/modsec_debug.log 44 SecDebugLogLevel 0 45 SecAuditEngine RelevantOnly 46 SecAuditLogRelevantStatus "^(?:5|4(?!04))" 47 SecAuditLogParts ABIJDEFHZ 48 SecAuditLogType Serial 49 SecAuditLog /var/log/httpd/modsec_audit.log 50 SecArgumentSeparator & 51 SecCookieFormat 0 52 SecTmpDir /var/lib/mod_security 53 SecDataDir /var/lib/mod_security 54
대충 테스트 해보니 파일의 이름이나 php의 업로드 용량 제한문제는 아닌 듯 하다.
급한대로(?) line 33~34를 주석처리 하면 오류가 사라진다.
또는
SecRuleRemoveById 200003 를 mod_security.conf에 추가해도 된다.
문제가 발생하는 룰을 제거하는 것으로 일단은 오류 발생은 안하고 있지만...
나중에 다시 한 번 봐야할 것 같다. mod_security를 최신버전으로 다시 설치하면 어떨까????
728x90
반응형
from http://aegypius.tistory.com/137 by ccl(S) rewrite - 2021-06-25 00:25:05