0x00 CRLF注入漏洞
0x01 目录穿越漏洞
Nginx在配置别名(Alias)的时候,如果忘记加/,将造成一个目录穿越漏洞。
错误的配置文件示例(原本的目的是为了让用户访问到/home/目录下的文件):
location /files {
alias /home/;
}
Payload:
http://your-ip:8081/files../ ,成功穿越到根目录:
0x02 add_header被覆盖
Nginx配置文件子块(server、location、if)中的add_header,将会覆盖父块中的add_header添加的HTTP头,造成一些安全隐患。
如下列代码,整站(父块中)添加了CSP头:
add_header Content-Security-Policy "default-src 'self'";
add_header X-Frame-Options DENY;
location = /test1 {
rewrite ^(.*)$ /xss.html break;
}
location = /test2 {
add_header X-Content-Type-Options nosniff;
rewrite ^(.*)$ /xss.html break;
}
但/test2的location中又添加了X-Content-Type-Options头,导致父块中的add_header全部失效:
XSS可被触发:
0x03 nginx文件解析漏洞
用户配置不当造成的解析漏洞。
访问图片后缀改成 .png/.php
参考文案
https://github.com/vulhub/vulhub/tree/master/nginx/insecure-configuration
https://github.com/vulhub/vulhub/tree/master/nginx/nginx_parsing_vulnerability