← 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);

더 읽기