PHP-014 / 初級
アップロードファイルの拡張子・MIME のみ信頼
なぜ問題になるのか?
クライアントが送る Content-Type と拡張子は偽造可能で、.php.jpg などの回避もあります。
修正方法
php
$request->validate(['img' => 'required|image|mimes:jpg,png|max:2048']);
$path = $request->file('img')->store('avatars', 'private'); // ランダムなファイル名、非公開ディスク