自定义 apache mod 安全性以接受 content-type=text/plain
Customizing apache mod security to accept content-type=text/plain
在我们当前的环境中,我们有一个面向 Internet 的 Web 应用程序,并且所有传入的流量都通过 apache 反向代理路由。在这个反向代理上,我们也配置了 ModSecurity。
现在,我们的一些入站请求具有 content-type=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 文件,其中我们有 disabled/customized 一些规则。我只是不知道如何添加这个。
PS:根据这个 post (https://github.com/SpiderLabs/owasp-modsecurity-crs/issues/208),这个问题已经解决了,但是我们将升级我们的规则集。
您应该有一个 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。
在我们当前的环境中,我们有一个面向 Internet 的 Web 应用程序,并且所有传入的流量都通过 apache 反向代理路由。在这个反向代理上,我们也配置了 ModSecurity。
现在,我们的一些入站请求具有 content-type=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 文件,其中我们有 disabled/customized 一些规则。我只是不知道如何添加这个。
PS:根据这个 post (https://github.com/SpiderLabs/owasp-modsecurity-crs/issues/208),这个问题已经解决了,但是我们将升级我们的规则集。
您应该有一个 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。