Deep prevention
Defense-in-depth principle is familiar to security professionals, which shows the value of redundant security measures, which has been proved by history.
The principle of defense in depth can be extended to other fields, not just programming. Skydivers who have used spare umbrellas can prove how valuable it is to have redundant safety measures, although people never want the main umbrella to fail. Redundant safety measures may play an important role in the potential failure of main safety measures.
Back to the field of programming, adhering to the principle of deep prevention requires that you always have a backup plan. If one security measure fails, the other must provide some protection. For example, it is a good habit to re-authenticate users before they perform important operations, even though there are no known defects in your user authentication logic. If an unauthenticated user somehow pretends to be another user, prompting for a password may prevent the unauthenticated (unauthenticated) user from performing some key operations.
Although defense in depth is a reasonable principle, excessive security measures can only increase costs and reduce value.
Small power
I used to have a car with a servant key. This key can only be used for ignition, so it can't open the door, console and trunk. It can only be used to start a car. I can give it to the parking attendant (or leave it on the ignition). I'm sure this key can't be used for other purposes.
It makes sense to give the parking attendant a key that can't open the console or trunk. After all, you may want to put valuables in these places. But I don't think it makes sense why it can't open the door. Of course, this is because my point is to take back authority. I wonder why the parking attendant was deprived of the right to open the door. This is a very bad point of view in programming. On the contrary, you should consider what authority is necessary, and only give everyone as little authority as possible to complete his work.
One reason why the servant key can't open the car door is that this key can be copied, and this copied key may be used to steal cars in the future. This situation sounds unlikely, but this example shows that unnecessary authorization will increase your risk, even if you add a little authority. Risk minimization is the main component of security program development.
You don't have to consider all the ways in which rights are abused. In fact, it is almost impossible for you to predict the actions of every potential attacker.
Simple is beauty
Complexity breeds mistakes, and mistakes can lead to security loopholes. This simple fact explains why simplicity is so important for a secure application. Unnecessary complexity is as bad as unnecessary risk.
Exposure minimization
PHP applications require frequent communication between PHP and external data sources. The main external data sources are client browsers and databases. If you track the data correctly, you can determine what data is exposed. The Internet is the main exposure source, because it is a very public network, and you must always be careful to prevent data from being exposed on the Internet.
Data exposure does not necessarily mean security risks. However, data leakage must be minimized. For example, when a user enters the payment system and transmits his credit card data to your server, you should use SSL to protect it. If you want to display his credit card number on a confirmation page, because the card number information is sent from the server to his client, you should also use SSL to protect it.
For example, in the previous example, displaying the credit card number obviously increases the chance of exposure. SSL can indeed reduce the risk, but a good solution is to completely eliminate the risk by displaying only the last four digits.
In order to reduce the exposure of sensitive data, Changping Computer Training believes that you must confirm which data are sensitive and track them at the same time to prevent all unnecessary data exposure. In this book, I will show some skills to help you protect many common sensitive data.