← PHP / Laravel · Contents

PHP-099 / Intermediate

Self-privilege escalation (allowing role changes through mass updates)

A01:2021 Broken Access Control · CWE-915 Mass Assignment

Why is this a problem?

The profile-edit API accepts the role field as well.

How to fix it

php
$request->user()->update($request->only(['name', 'bio']));

Further reading