← PHP / Laravel · 目次

PHP-079 / 中級

シンボリックリンク追跡による任意ファイル露出(public storage link)

A01:2021 Broken Access Control · CWE-59 Link Following

なぜ問題になるのか?

アップロードディレクトリに作成した symlink が /etc を指す場合があります。

修正方法

php
$real = realpath($path);
abort_unless($real && str_starts_with($real, realpath(storage_path('app/uploads'))), 404);

参考資料