自定义apache mod安全性以接受content-type = text / plain

时间:2017-01-12 03:33:45

标签: apache security mod-security mod-security2

在我们当前的环境中,我们有一个面向互联网的Web应用程序,所有传入的流量都通过apache反向代理进行路由。在这个反向代理上,我们也配置了ModSecurity。

现在,我们的一些入站请求的内容类型= text / plain。所有这些请求都被具有以下日志的ModSec规则集阻止:

[Tue Jan 10 11:14:31 2017] [error] [client 175.45.116.65] ModSecurity:  [file "/etc/httpd/conf/crs/activated_rules/modsecurity_crs_30_http_policy.conf"] [line "64"] [id "960010"] [rev "2"] [msg "Request content type is not allowed by policy"] [data "text/plain"] [severity "CRITICAL"] [ver "OWASP_CRS/2.2.6"] [maturity "9"] [accuracy "9"] [tag "OWASP_CRS/POLICY/ENCODING_NOT_ALLOWED"] [tag "WASCTC/WASC-20"] [tag "OWASP_TOP_10/A1"] [tag "OWASP_AppSensor/EE2"] [tag "PCI/12.1"] Access denied with code 403 (phase 1). Match of "rx ^%{tx.allowed_request_content_type}$" against "TX:0" required. [hostname "hadToRemove"] [uri "hadToRemove"] [unique_id "WHQnZwoMD1QAACBlB70AAAAN"]

现在,如果我们想将text / plain作为可接受的内容类型,我们应该如何添加它。我们已经有一个conf文件,我们已经禁用/定制了一些规则。我只是不知道如何添加这个。

PS:根据这篇文章(https://github.com/SpiderLabs/owasp-modsecurity-crs/issues/208),这个问题已经修复,但为此我们将升级我们的规则集。

1 个答案:

答案 0 :(得分:1)

你应该有一个modsecurity_crs_10_setup.conf文件,其中配置了这些类型的东西,然后被各种其他规则使用。

该文件的行如下所示:

#
# Set the following policy settings here and they will be propagated to the 30 rules
# file (modsecurity_crs_30_http_policy.conf) by using macro expansion.  
# If you run into false positves, you can adjust the settings here.
#
SecAction \
  "id:'900012', \
  phase:1, \
  t:none, \
  setvar:'tx.allowed_methods=GET HEAD POST OPTIONS', \
  setvar:'tx.allowed_request_content_type=application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/x-amf|application/json', \

您可以更改最后一行以允许text / plain:

  setvar:'tx.allowed_request_content_type=application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/x-amf|application/json|text/plain', \

然后重启Apache。