← PHP / Laravel · Contents

PHP-029 / Intermediate

Trusting client-supplied role values

A01:2021 Broken Access Control · CWE-285 Improper Authorization

Why is this a problem?

Privileges are obtained by tampering with role values in hidden fields or cookies.

How to fix it

php
if ($request->user()->can('manage-users')) { return $this->adminPanel(); }  // Server-side policy

Further reading