nginx 配置错误而导致目录遍历漏洞

漏洞版本:

nginx(Tested at 1.1.10)

漏洞描述:

nginx是一款高性能的web服务器,使用非常广泛,其不仅经常被用作反向代理

在nginx中开启autoindex,配置不规范而造成目录遍历漏洞

配置如下:
  1. server {
  2. listen 80;
  3. server_name sebug.net;
  4. index index.htm index.html;
  5. root /home/wwwroot/www;
  6. access_log off;
  7. location /paper {
  8. alias /home/wwwroot/paper/;
  9. autoindex on;
  10. }
  11. }
注意 这里/home/wwwroot/paper/;  有个/

当你浏览http://sebug.net/paper/,正常情况应该遍历/home/wwwroot/paper/这个目录,但是如果访问http://sebug.net/paper../, 这个的话就会遍历/home/wwwroot/这个目录了
<* 参考

http://luoq.net/ais/1191/

*>

安全建议:

使用如下配置
location /paper {
    alias /home/wwwroot/paper;
或
location /paper/ {
    alias /home/wwwroot/paper/;

评论关闭。