← PHP / Laravel · Contents

PHP-037 / Intermediate

Storing sensitive files on a public disk

A01:2021 Broken Access Control · CWE-200 Exposure of Sensitive Information

Why is this a problem?

Anyone who knows the path can access copies of identity documents and similar files.

How to fix it

php
$path = $request->file('id_card')->store('ids', 'local');   // Private disk
// Serve after authorization through Storage::download or a temporary signed URL

Further reading