漏扫 X-Content-Type-Options X-XSS-Protection Strict-Transport-Security X-Frame-Options

发布时间 2023-11-06 14:56:39作者: 茗飨

web应用nginx部署未设置头部,导致可能出现安全问题

【未设置X-Content-Type-Options响应头】

【未设置X-XSS-Protection响应头】

【未设置Strict-Transport-Security响应头】

【X-Frame-Options头未设置】

 

Content-Type(内容类型),一般是指网页中存在的 Content-Type,用于定义网络文件的类型和网页的编码,决定浏览器将以什么形式、什么编码读取这个文件,这就是经常看到一些 PHP 网页点击的结果却是下载一个文件或一张图片的原因。

Content-Type 标头告诉客户端实际返回的内容的内容类型。通常浏览器可以通过嗅探内容本身的方法来决定它是什么类型,而不是看响应中的content-type值。通过设置 X-Content-Type-Options:如果content-type和期望的类型匹配,则不需要嗅探,只能从外部加载确定类型的资源。

add_header 'Referrer-Policy' 'origin';

add_header X-Xss-header “1;mode=block”;

add_header X-XSS-Protection "1; mode=block";

add_header X-Download-Options "noopen" always;

add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";

add_header X-Frame-Options SAMEORIGIN;

add_header X-Permitted-Cross-Domain-Policies "master-only";

add_header Content-Security-Policy "default-src 'self' data: *.xxx.com 'unsafe-inline' 'unsafe-eval' mediastream: ";

add_header X-Content-Type-Options: nosniff;

 

 location / {
        ....,
          add_header X-Content-Type-Options nosniff;
      add_header X-XSS-Protection "1; mode=block";
      add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
      add_header X-Frame-Options SAMEORIGIN;
}