【已解决】“X-Content-Type-Options”头缺失或不安全

简介: 【已解决】“X-Content-Type-Options”头缺失或不安全

Appscan是一款安全漏洞扫描软件,由IBM公司研发,后又被卖给了印度公司HCL。

web安全测试中,今天我们说下扫描结果中包含X-Content-Type-Options请求头header的缺失或不安全的时候,我们该如何应对。

风险:可能会收集有关 Web 应用程序的敏感信息,如用户名、密码、机器名和/或敏感文件位置;可能会劝说初级用户提供诸如用户名、密码、信用卡号、社会保险号等敏感信息。

技术原因:未设置此header时,会加载所有script文件,即使它的MIME不是text/javascript等。运行潜在的脚本文件,会存在丢失数据的风险。

简单理解为:通过设置”X-Content-Type-Options: nosniff”响应标头,对 scriptstyleSheet 在执行是通过MIME 类型来过滤掉不安全的文件。

X-Content-Type-Options: nosniff

如果响应中接收到 “nosniff” 指令,则浏览器不会加载“script”文件,除非 MIME 类型匹配以下值之一:

  • “application/ecmascript”
  • “application/javascript”
  • “application/x-javascript”
  • “text/ecmascript”
  • “text/javascript”
  • “text/jscript”
  • “text/x-javascript”
  • “text/vbs”
  • “text/vbscript”

Nginx Web服务器

  • 在服务器块下的nginx.conf中添加以下参数
1.  server {
2.       listen       443;
3.       server_name  ds.v.com;  # 驾驶安全
4. 
5. 
6. location / {
7.           client_body_timeout  7200;
8.           proxy_read_timeout 7200;
9.           proxy_send_timeout 7200;
10.           proxy_pass   http://127.0.0.1:9005/;
11.           proxy_cookie_path / "/; httponly; secure; SameSite=Lax";
12. add_header X-Content-Type-Options nosniff;
13.       }
14. 
15.       ssl_certificate     "/etc/nginx/ssl/ds/ds.v.com.pem";
16.       ssl_certificate_key "/etc/nginx/ssl/ds/ds.v.com.key";
17.       # ssl_protocols      TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
18.       ssl_protocols      TLSv1.3;
19. 
20.       ssl_session_cache shared:SSL:1m;
21.       ssl_session_timeout  10m;
22.       ssl_ciphers HIGH:!aNULL:!MD5;
23.       ssl_prefer_server_ciphers on;
24.     }

保存nginx.conf文件, 然后重新启动Nginx以查看结果。



相关文章
|
JSON API 数据格式
Uniapp~动态修改 请求头的content-type 的值
Uniapp~动态修改 请求头的content-type 的值
1412 0
Uniapp~动态修改 请求头的content-type 的值
|
XML JSON 数据处理
postman 中 body的form-data,x-www-form-urlencoded,raw,binary含义
postman 中 body的form-data,x-www-form-urlencoded,raw,binary含义
565 0
postman 中 body的form-data,x-www-form-urlencoded,raw,binary含义
|
5月前
|
JSON 缓存 JavaScript
【HTTP】请求“报头”(Host、Content-Length/Content-Type、User-Agent(简称 UA))
【HTTP】请求“报头”(Host、Content-Length/Content-Type、User-Agent(简称 UA))
219 1
|
10月前
|
监控 安全 JavaScript
掌握X-Content-Type-Options头的防护之力
掌握X-Content-Type-Options头的防护之力
392 0
head 插件 Content-Type header [application/x-www-form-urlencoded] is not supported
head 插件 Content-Type header [application/x-www-form-urlencoded] is not supported
165 1
|
10月前
|
C++
c++ - 警告 : treating ‘c-header‘ input as ‘c++-header‘ when in C++ mode, 此行为已弃用
c++ - 警告 : treating ‘c-header‘ input as ‘c++-header‘ when in C++ mode, 此行为已弃用
|
JSON 数据格式
axios.post请求出错:Request header field content-type is not allowed by Access-Control-Allow-Headers in……
axios.post请求出错:Request header field content-type is not allowed by Access-Control-Allow-Headers in……
|
JavaScript 前端开发 应用服务中间件
【已解决】“Content-Security-Policy”头缺失
【已解决】“Content-Security-Policy”头缺失
3368 0
|
JavaScript 前端开发
JavaScript 无法获取响应 header 的 Content-Disposition 字段
JavaScript 无法获取响应 header 的 Content-Disposition 字段
1052 0
JavaScript 无法获取响应 header 的 Content-Disposition 字段
|
JSON JavaScript API
axios设置content-type
axios设置content-type
1045 0