漏洞原因:
Nginx配置文件子块(server、location、if)中的add_header,将会覆盖父块中的add_header添加的HTTP头,造成一些安全隐患。
如以下:
因为/test2中的location中又添加了X-Content-Type-Options头,导致父块中的防止xss的csp头等add_header全部失效。
漏洞演示:
访问根目录csp头存在:
访问test1存在:
访问test2不存在:
test2test1都引用了static/app.js,static/app.js的源码:
window.onload = function() {
var m = document.getElementById('m');
m.innerHTML = location.hash.substr(1);
}
访问:/test1#成功执行xss:
可见当存在覆盖时,就算csp头存在也会失效