Home > Article > Backend Development > PHP security-least privilege
Minimum permissions
I used to have a car that had a maid key. This key can only be used in the ignition, so it cannot open the doors, console, or trunk. It can only be used to start the car. I can give it to the parking attendant (or leave it in the ignition), and I confirm that the key cannot be used for other purposes.
It makes sense to give the parking attendant a key that won't open the console or trunk; after all, you might want to keep valuables in those places. But what doesn't make sense to me is why it can't open the door. Of course, this is because my point is about the revocation of authority. I was wondering why the parking attendant was stripped of his authority to open the door. In programming, this is a very bad idea. Instead, you should consider what permissions are necessary and give each person as little permission as they need to do their job.
One reason why a maid key cannot open a car door is that the key can be copied, and the copied key could be used to steal a car in the future. This scenario may sound unlikely, but it's an example of how unnecessary authorization can increase your risk, even for a small increase in permissions. Risk minimization is a major component of safety program development.
You don't need to think about all the ways a permission can be abused. In fact, it’s nearly impossible to predict every potential attacker’s actions.
The above is the content of PHP security-minimum permissions. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!