缓解 CVE-2017-5638 Apache Struts2 漏洞
Mitigating CVE-2017-5638 Apache Struts2 vulnerability
如何缓解 Struts 2 恶意 Content-Type
攻击 而不 更新我的 Java 代码?
攻击详情S2-045。
Apache 的 mod_rewrite 可以过滤掉不良内容类型。
可以进行更高级的检查 - 但这会检查我们不希望在传入的 content-type header:
中看到的字符
RewriteCond %{HTTP:Content-type} [$\#()]
RewriteRule . [F,L]
我会将“%”、“}”和“{”字符添加到条件中,因为它们也无效 Content-type header 条目并且存在于 POC 中利用此漏洞的负载。
RewriteCond %{HTTP:Content-type} [$\#()%}{]
RewriteRule . [F,L]
对不起,如果我的语法有误,因为我还没有测试过这个条目。
P.S。我什至会冒险添加“@”、“?”和 ';'字符,但如果过滤这些可能会破坏应用程序,因为我认为它们实际上在技术上是允许的,但我从未在我们的任何应用程序实现中看到 content-type header。
启用 mod_rewrite 后,您可以将此添加到 httpd.conf 或虚拟主机中:
# MITIGATE CVE-2017-5638
RewriteCond %{HTTP:Content-type} [$\#()%}{'"] [OR]
RewriteCond %{HTTP:Content-Disposition} [$\#()%}{'"] [OR]
RewriteCond %{HTTP:Content-Length} [$\#()%}{'"]
RewriteRule . "-" [F,L]
如何缓解 Struts 2 恶意 Content-Type
攻击 而不 更新我的 Java 代码?
攻击详情S2-045。
Apache 的 mod_rewrite 可以过滤掉不良内容类型。
可以进行更高级的检查 - 但这会检查我们不希望在传入的 content-type header:
中看到的字符RewriteCond %{HTTP:Content-type} [$\#()]
RewriteRule . [F,L]
我会将“%”、“}”和“{”字符添加到条件中,因为它们也无效 Content-type header 条目并且存在于 POC 中利用此漏洞的负载。
RewriteCond %{HTTP:Content-type} [$\#()%}{]
RewriteRule . [F,L]
对不起,如果我的语法有误,因为我还没有测试过这个条目。
P.S。我什至会冒险添加“@”、“?”和 ';'字符,但如果过滤这些可能会破坏应用程序,因为我认为它们实际上在技术上是允许的,但我从未在我们的任何应用程序实现中看到 content-type header。
启用 mod_rewrite 后,您可以将此添加到 httpd.conf 或虚拟主机中:
# MITIGATE CVE-2017-5638
RewriteCond %{HTTP:Content-type} [$\#()%}{'"] [OR]
RewriteCond %{HTTP:Content-Disposition} [$\#()%}{'"] [OR]
RewriteCond %{HTTP:Content-Length} [$\#()%}{'"]
RewriteRule . "-" [F,L]