← PHP / Laravel · 目录

PHP-079 / 中级

跟随符号链接导致任意文件暴露(公开存储链接)

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

为什么存在问题?

在上传目录创建的符号链接可能指向 /etc。

如何修复

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

延伸阅读