Several PHP vulnerabilities to note _php tips

Source: Internet
Author: User
Several PHP vulnerabilities to note
Several important php.ini options
Register Globals
The default value for the Register_globals option for Php>=4.2.0,php.ini is off, and when Register_globals is set to ON, the program can receive various environment variables from the server, including form-submitted variables. And because PHP does not have to initialize the value of variables in advance, it can cause great security risks.
Example 1:
Copy Code code as follows:

Check_admin () is used to check the current user right, and if the admin sets the $is_admin variable to True, then the following determines if the variable is true, and then performs some of the administrative actions
ex1.php
  
if (Check_admin ())
{
$is _admin = true;
}
if ($is _admin)
{
Do_something ();
}
?>

This section of code does not initialize $is_admin in advance to Flase, if Register_globals is on, then we submit http://www.sectop.com/ex1.php?is_admin=true directly, You can bypass the validation of Check_admin ()
Example 2:
Copy Code code as follows:

ex2.php
  
if (Isset ($_session["username"]))
{
Do_something ();
}
Else
{
echo "You are not logged in!";
}
?>

Copy Code code as follows:

ex1.php
  
$dir = $_get["dir"];
if (Isset ($dir))
{
echo "";
System ("Ls-al". $dir);
echo "";
}
?>


Mixed eval (string code_str)//eval injection typically occurs when an attacker can control the input string
ex2.php
Copy Code code as follows:
  
$var = "Var";
if (Isset ($_get["arg"))
{
$arg = $_get["arg"];
Eval ("$var = $arg;");
echo "$var =". $var;
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.