本文介绍: X-Content-Type-Options HTTP 消息头相当于一个提示标志,被服务器用来提示客户端一定要遵循在 Content-Type 首部中对 MIME 类型 的设定,而不能对其进行修改。Web 服务器对于 HTTP 请求响应头中缺少 X-Download-Options,这将导致浏览器提供的安全特性失效漏洞危害: Web 服务器对于 HTTP 请求响应头中缺少 X-Download-Options,这将导致浏览器提供的安全特性失效,更容易遭受 Web 前端黑客攻击影响

通过HTTP获取远端WWW服务信息

漏洞详情

插件检测远端HTTP Server信息。这可能使得攻击者了解远程系统类型以便进行下一步攻击

漏洞仅是为了信息获取,建议隐藏敏感信息

解决方法

隐藏版本号

进入$CATALINA_HOMElib 目录中,

依次执行如下命令

mkdir -p org/apache/catalina/util //创建文件夹名称不可更改
cd org/apache/catalina/util //进入目录
vim ServerInfo.properties //创建文件写入内容
server.info=Apache Tomcat //这里编写自定义版本信息

目标X-Content-Type-Options等响应缺失

漏洞详情:

X-Content-Type-Options HTTP 消息头相当于一个提示标志,被服务用来提示客户端一定要遵循在 Content-Type 首部中对 MIME 类型 的设定,而不能对其进行修改。这就禁用客户端的 MIME 类型嗅探行为,换句话说,也就是意味着网站管理员确定自己设置没有问题

X-Content-Type-Options响应头的缺失使得目标URL更易遭受跨站脚本攻击

X-XSS-Protection响应头缺失

X-Frame-Options

Strict-Transport-Security

解决方法

打开tomcat/conf/web.xml,增加如下配置

   <filter&gt;
        <filter-name&gt;httpHeaderSecurity</filter-name&gt;
        <filter-class&gt;org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class&gt;
        <async-supported&gt;true</async-supported&gt;
        <init-param&gt;
            <param-name>hstsEnabled</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>hstsMaxAgeSeconds</param-name>
            <param-value>31536000</param-value>
        </init-param>
        <init-param>
            <param-name>antiClickJackingEnabled</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>antiClickJackingOption</param-name>
            <param-value>SAMEORIGIN</param-value>
        </init-param>
        <init-param>
            <param-name>blockContentTypeSniffingEnabled</param-name> <!-- X-Content-Type-Options 默认: true(nosniff) -->    
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>xssProtectionEnabled</param-name> <!-- X-XSS-Protection 默认: true(1; mode=block) -->    
            <param-value>true</param-value>
        </init-param>
    </filter>



   <filter-mapping>
        <filter-name>httpHeaderSecurity</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
   </filter-mapping>

效果如图

检测目标X-Download-Options响应头缺失

漏洞详情

Web 服务器对于 HTTP 请求响应头中缺少 X-Download-Options,这将导致浏览器提供的安全特性失效漏洞危害: Web 服务器对于 HTTP 请求的响应头中缺少 X-Download-Options,这将导致浏览器提供的安全特性失效,更容易遭受 Web 前端黑客攻击的影响

解决方法:

在Tomcat服务器的web.xml配置路径tomcat/conf/web.xml修改内容如下

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  version="3.1">
  <!-- 以上是tomcat中本身存在,下面是新添加内容-->
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>http method security</web-resource-name>
            <url-pattern>/*</url-pattern>
            <http-method>PUT</http-method>
            <http-method>DELETE</http-method>
            <http-method>HEAD</http-method>
            <http-method>TRACE</http-method>
        </web-resource-collection>
        <auth-constraint/>
    </security-constraint>

重新部署程序重启tomcat即可完成

下图

检测目标Content-Security-Policy响应头缺失

漏洞详情

HTTP 响应头Content-Security-Policy允许站点管理者控制用户代理能够指定页面加载哪些资源。除了少数例外情况,设置政策主要涉及指定服务器的源和脚本结束点。

Content-Security-Policy响应头的缺失使得目标URL更易遭受跨站脚本攻击。

解决办法

将您的服务器配置发送“Content-Security-Policy”头。对于 Apache,请参阅:http://httpd.apache.org/docs/2.2/mod/mod_headers.html对于 IIS,请参阅:https://technet.microsoft.com/pl-pl/library/cc753133%28v=ws.10%29.aspx对于 nginx,请参阅:http://nginx.org/en/docs/http/ngx_http_headers_module.html

tomcat: web.xml 添加如下

    <filter>
        <filter-name>HttpHeaderSecurityFilter</filter-name>
        <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
        <init-param>
           <param-name>contentSecurityPolicy</param-name>
           <param-value>default-src 'self'; script-src 'self' tran.bfcec.com.cn:8080 tran.bfcec.com.cn;</param-value>
        </init-param>
    </filter>
 
     <filter-mapping>
        <filter-name>HttpHeaderSecurityFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

原文地址:https://blog.csdn.net/m0_61069946/article/details/129652374

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_36182.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注