我的客户要我修复 My Web App 的 Web App 漏洞 以下是有关 My Web App 漏洞的消息
The Anti-MIME-Sniffing header X-Content-Type-Options was not set to 'nosniff'
This check is specific to Internet Explorer 8 and Google Chrome. Ensure each page sets a >Content-Type header and the X-CONTENT-TYPE-OPTIONS if the Content-Type header is unknown
虽然我已经找到了这个问题的一些解决方案,但我正在从 tomcat 配置中寻找解决方案。 是否可以更改 tomcat 配置来完成此操作?
请给我任何想法。
最佳答案
如果您使用的是 Tomcat 8,那真的很简单 - 将这两个部分添加到您的 web.xml 中:
<filter>
<filter-name>HeaderSecurityFilter</filter-name>
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HeaderSecurityFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
服务器响应现在有“nosniff”和 X-Frame-Options:默认拒绝
关于java - 如何将 X-Content-Type-Options 添加到 tomcat 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24182367/