← PHP / Laravel · Contents

PHP-060 / Intermediate

Long-term exposure of public storage URLs (Storage::url)

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

Why is this a problem?

Guessable public URLs remain accessible indefinitely.

How to fix it

php
return Storage::disk('s3')->temporaryUrl("invoices/{$id}.pdf", now()->addMinutes(5));

Further reading