← PHP / Laravel · Contents

PHP-090 / Beginner

Unlimited page size (per_page)

A04:2021 Insecure Design · CWE-770 Allocation of Resources Without Limits

Why is this a problem?

per_page=1000000 exhausts memory and database resources.

How to fix it

php
Post::paginate(min((int) $request->input('per_page', 20), 100));

Further reading