← PHP / Laravel · Contents

PHP-079 / Intermediate

Arbitrary file exposure through symlink following (public storage link)

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

Why is this a problem?

A symlink created in the upload directory can point to /etc.

How to fix it

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

Further reading