ディレクトリトラバーサル 09 - yujitounai/helloworld GitHub Wiki

ディレクトリトラバーサル-08

nginxのstaticの仕様によるディレクトリトラバーサル

location /static {
    alias /var/www/app/static/;
}

という設定があるとき

http://example.com/static..%2fsecrets/secret.key

にアクセスすると ファイルが取れる

攻撃方法

http://example.com/static..%2fsecrets/secret.key

対策

/ を付ける

// 脆弱性がない設定。static の後に / が存在する。
location /static/ {
    alias /var/www/app/static/;
}