Home > Article > Backend Development > PHP security-simplicity is beautiful
Complexity breeds errors, and errors can lead to security vulnerabilities. This simple fact illustrates why simplicity is so important for a secure application. Unnecessary complexity is just as bad as unnecessary risk.
For example, the following code is excerpted from a recent security vulnerability advisory:
##CODE:
<?php $search = (isset($_GET['search']) ? $_GET['search'] : ''); ?>
This process can confuse the fact that the $search variable is tainted*, especially to inexperienced developers. The above statement is equivalent to the following program:
CODE:
<?php $search = ''; if (isset($_GET['search'])) { $search = $_GET['search']; } ?>
## The above The two processing flows are exactly the same. Now please pay attention to the following statement:
$search = $_GET['search'];
* Annotation: A contaminated variable means that during program execution, the value of the variable is not directly specified by the assignment statement, but comes from other sources, such as console entry, database, etc.
The above is the content of PHP Security-Simplicity is Beautiful. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!