1. 加密会话(SSL)Cookie 中缺少 Secure 属性(解决)
- 在nginx中设置cookie属性,在配置文件中server模块设置:add_header Set-Cookie “Secure”; 利用fiddler抓包,查看请求响应中cookie是否包含secure属性
2. 检车到rc4密码套件(解决)
- rc4是弱密码套件,可以在ngnix配置文件中禁用该弱密码套件
- ngnix配置文件检测命令: ngnix -t
- ngnix配置文件重新加载: ngnix -s reload
- ngnix重启/停止: ngnix -s reopen/stop
- 配置详解参考:https://www.cnblogs.com/liang-wei/p/5849771.html
3. 针对ssl/tls的浏览器利用
- https://segmentfault.com/a/1190000012731888
- https://www.jdon.com/performance/best-nginx-configuration-for-security.html
4. missing “Content-Security-Policy”、“X-Content-Type-Options”、“X-xss-Protection”、“HTTP Strict-Transport-Security”header(解决)
- https://www.cnblogs.com/heyuqing/p/6215761.html 中:
- Nginx
- 在 server {}对象块中添加如下代码
- add_header Content-Security-Policy “default-src ‘self’;”;
- https://www.keakon.net/2016/02/10/折腾了一下nginx配置
- https://www.freebuf.com/articles/web/66827.html
- https://blog.youkuaiyun.com/u013310119/article/details/84861900
- X-xss-Protection 设置:防止xss攻击,(大多浏览器默认开启,如果未开启,进行设置)
- add_header X-XSS-Protection “1; mode=block”; # XSS 保护
- 0:禁止XSS过滤
- 1:启用XSS过滤。 如果检测到跨站脚本攻击,浏览器将清除页面中不安全的部分,但页面仍然可以访问。
- 1;mode=block:启用XSS过滤。 如果检测到攻击,浏览器将直接阻止页面加载
- X-Content-Type-Options :用来禁用浏览器内容嗅探行为。
- nosniff – 这个是唯一正确的设置,必须这样。
- Content-Security-Policy
- add_header Content-Security-Policy “default-src ‘self’;”;
- default-src ‘self’; 只允许同源下的资源
- script-src ‘self’; 只允许同源下的js
- script-src ‘self’ www.google-analytics.com ajax.googleapis.com; 允许同源以及两个地址下的js加载
- default-src ‘none’; script-src ‘self’; connect-src ‘self’; img-src ‘self’; style-src ‘self’; 多个资源时,后面的会覆盖前面的
- Strict-Transport-Security
location / { add_header Strict-Transport-Security max-age=86400; //max‐age:设置hsts的有效期,在这个有效期内,http访问域名都会自动内部转换成https }
// max-age Header always set Strict‐Transport‐Security "max‐age=63072000; includeSubDomains"`
max‐age:设置hsts的有效期,在这个有效期内,http访问域名都会自动内部转换成https
includeSubDomains :表示对子域名也生效
5. 发现可高速缓存的 SSL 页面(解决)
- https://www.cnblogs.com/tdcqma/p/5360522.html
- 在nginx配置文件中,进行设置
location ~.*\.(css|js|swf|php|htm|html)$ {
add_header Cache-Control no-store;
}
6. 不安全的http方法(解决)
- 加在了location中
if ($request_method !~ ^(GET|HEAD|POST|PUT|TRACE|OPTIONS|PATCH)$) {
return 444;
}
7. 未实施的加密
- 设置了重定向
server {
listen 80;
server_name servername;
rewrite ^/(.*) https://$server_name$request_uri? permanent;
}